Skip to content

Commit

Permalink
<feat>(client&connection): init client&connection&account code (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
JyFangYang authored Aug 6, 2024
1 parent d2b7729 commit cbcc97b
Show file tree
Hide file tree
Showing 27 changed files with 1,603 additions and 10 deletions.
12 changes: 4 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ dependencies {
exclude group: "io.netty"
exclude group: 'org.fisco-bcos', module: 'tcnative'
}

implementation 'org.web3j:core:4.9.8'

// implementation('org.fisco-bcos.java-sdk:fisco-bcos-sdk-abi:2.10.0-SNAPSHOT')

// Use JUnit test framework
Expand Down Expand Up @@ -124,15 +127,8 @@ sourceSets {

shadowJar {
dependsOn(copyHooks)
dependencies {
//排除掉io.netty:.*,不打包进fat jar
exclude(dependency('io.netty:.*'))
}
mergeServiceFiles()
minimize{
//不优化处理io.grpc:.*,直接打进fat jar
exclude(dependency('io.grpc:.*'))
}
minimize()
}


Expand Down
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
9 changes: 9 additions & 0 deletions settings.gradle
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'
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) {}
}
Loading

0 comments on commit cbcc97b

Please sign in to comment.