Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<feat>(client&connection): init client&connection&account code #3

Merged
merged 4 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading