-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<feat>(client&connection): init client&connection&account code (#3)
- Loading branch information
1 parent
d2b7729
commit cbcc97b
Showing
27 changed files
with
1,603 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
pluginManagement { | ||
repositories { | ||
maven { | ||
url 'https://maven.aliyun.com/repository/gradle-plugin' | ||
} | ||
gradlePluginPortal() | ||
} | ||
} | ||
rootProject.name = 'WeCross-Web3-Stub' |
61 changes: 61 additions & 0 deletions
61
src/main/java/com/webank/wecross/stub/web3/Web3BaseStubFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.webank.wecross.stub.web3; | ||
|
||
import com.webank.wecross.stub.Account; | ||
import com.webank.wecross.stub.Connection; | ||
import com.webank.wecross.stub.Driver; | ||
import com.webank.wecross.stub.StubFactory; | ||
import com.webank.wecross.stub.WeCrossContext; | ||
import com.webank.wecross.stub.web3.account.Web3AccountFactory; | ||
import com.webank.wecross.stub.web3.common.Web3Constant; | ||
import java.util.Map; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class Web3BaseStubFactory implements StubFactory { | ||
private static final Logger logger = LoggerFactory.getLogger(Web3BaseStubFactory.class); | ||
|
||
@Override | ||
public void init(WeCrossContext weCrossContext) {} | ||
|
||
@Override | ||
public Driver newDriver() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Connection newConnection(String path) { | ||
try { | ||
logger.info("New connection: {}", path); | ||
Web3Connection connection = Web3ConnectionFactory.build(path, Web3Constant.STUB_TOML_NAME); | ||
|
||
// check proxy contract | ||
if (!connection.hasProxyDeployed()) { | ||
String errorMsg = "WeCrossProxy error: WeCrossProxy contract has not been deployed!"; | ||
System.out.println(errorMsg); | ||
throw new Exception(errorMsg); | ||
} | ||
|
||
// check hub contract | ||
if (!connection.hasHubDeployed()) { | ||
String errorMsg = "WeCrossHub error: WeCrossHub contract has not been deployed!"; | ||
System.out.println(errorMsg); | ||
throw new Exception(errorMsg); | ||
} | ||
return connection; | ||
} catch (Exception e) { | ||
logger.error("New connection fail, e: ", e); | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public Account newAccount(Map<String, Object> properties) { | ||
return Web3AccountFactory.build(properties); | ||
} | ||
|
||
@Override | ||
public void generateAccount(String path, String[] args) {} | ||
|
||
@Override | ||
public void generateConnection(String path, String[] args) {} | ||
} |
Oops, something went wrong.