org.fisco.bcos.web3j.abi.datatypes.Address Java Examples

The following examples show how to use org.fisco.bcos.web3j.abi.datatypes.Address. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Topic.java    From WeEvent with Apache License 2.0 6 votes vote down vote up
public Tuple5<List<String>, List<BigInteger>, List<BigInteger>, List<BigInteger>, List<String>> getFlushSnapshotInput(TransactionReceipt transactionReceipt) {
    String data = transactionReceipt.getInput().substring(10);
    final Function function = new Function(FUNC_FLUSHSNAPSHOT, 
            Arrays.<Type>asList(), 
            Arrays.<TypeReference<?>>asList(
                new TypeReference<DynamicArray<Utf8String>>() {},
                new TypeReference<DynamicArray<Uint256>>() {},
                new TypeReference<DynamicArray<Uint256>>() {},
                new TypeReference<DynamicArray<Uint256>>() {},
                new TypeReference<DynamicArray<Address>>() {}));
    List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());;
    return new Tuple5<List<String>, List<BigInteger>, List<BigInteger>, List<BigInteger>, List<String>>(

            convertToNative((List<Utf8String>) results.get(0).getValue()), 
            convertToNative((List<Uint256>) results.get(1).getValue()), 
            convertToNative((List<Uint256>) results.get(2).getValue()), 
            convertToNative((List<Uint256>) results.get(3).getValue()), 
            convertToNative((List<Address>) results.get(4).getValue())
            );
}
 
Example #2
Source File: Evidence.java    From evidenceSample with Apache License 2.0 6 votes vote down vote up
public RemoteCall<Tuple7<String, String, String, List<BigInteger>, List<byte[]>, List<byte[]>, List<String>>> getEvidence() {
    final Function function = new Function(FUNC_GETEVIDENCE, 
            Arrays.<Type>asList(), 
            Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<DynamicArray<Uint8>>() {}, new TypeReference<DynamicArray<Bytes32>>() {}, new TypeReference<DynamicArray<Bytes32>>() {}, new TypeReference<DynamicArray<Address>>() {}));
    return new RemoteCall<Tuple7<String, String, String, List<BigInteger>, List<byte[]>, List<byte[]>, List<String>>>(
            new Callable<Tuple7<String, String, String, List<BigInteger>, List<byte[]>, List<byte[]>, List<String>>>() {
                @Override
                public Tuple7<String, String, String, List<BigInteger>, List<byte[]>, List<byte[]>, List<String>> call() throws Exception {
                    List<Type> results = executeCallMultipleValueReturn(function);
                    return new Tuple7<String, String, String, List<BigInteger>, List<byte[]>, List<byte[]>, List<String>>(
                            (String) results.get(0).getValue(), 
                            (String) results.get(1).getValue(), 
                            (String) results.get(2).getValue(), 
                            convertToNative((List<Uint8>) results.get(3).getValue()), 
                            convertToNative((List<Bytes32>) results.get(4).getValue()), 
                            convertToNative((List<Bytes32>) results.get(5).getValue()), 
                            convertToNative((List<Address>) results.get(6).getValue()));
                }
            });
}
 
Example #3
Source File: EvidenceVerify.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
public RemoteCall<TransactionReceipt> insertEvidence(
        String evi,
        String info,
        String id,
        String signAddr,
        byte[] message,
        BigInteger v,
        byte[] r,
        byte[] s) {
    final Function function =
            new Function(
                    FUNC_INSERTEVIDENCE,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(evi),
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(info),
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(id),
                            new org.fisco.bcos.web3j.abi.datatypes.Address(signAddr),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(message),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Uint8(v),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(r),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(s)),
                    Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #4
Source File: EventEncoderTest.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
@Test
public void testEventbuildMethodSignature8() {
    Event event =
            new Event(
                    "test8",
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<Utf8String>() {},
                            new TypeReference<Address>() {},
                            new TypeReference<Uint256>() {},
                            new TypeReference<Int256>() {}));

    assertThat(
            EventEncoder.buildMethodSignature(event.getName(), event.getParameters()),
            is("test8(string,address,uint256,int256)"));

    assertThat(
            EventEncoder.encode(event),
            is("0xfa3d7a982eb00eec003de55d3e9266fa4b9ccd6a3a067b75b24ef6b4cb9b12c4"));
    assertThat(
            EventEncoder.buildEventSignature("test8(string,address,uint256,int256)"),
            is("0xfa3d7a982eb00eec003de55d3e9266fa4b9ccd6a3a067b75b24ef6b4cb9b12c4"));
}
 
Example #5
Source File: BcosApp.java    From evidenceSample with Apache License 2.0 6 votes vote down vote up
public Address deployContract(String keyStoreFileName,String keyStorePassword, String keyPassword) throws Exception {
	if (web3j == null )
		return null;
	Credentials credentials=loadkey(keyStoreFileName,keyStorePassword,keyPassword);
	if(credentials==null){
		return null;
	}
    //Service service = context.getBean(Service.class);
    //service.run();
    PublicAddressConf conf = context.getBean(PublicAddressConf.class);
       ConcurrentHashMap<String, String> addressConf = conf.getAllPublicAddress();
       List<String> arrayList = addressConf.values().stream().map(String::new).collect(Collectors.toCollection(ArrayList::new));
       try {
           evidenceSignersData = EvidenceSignersData.deploy(web3j, credentials, new StaticGasProvider(gasPrice, gasLimited), arrayList).send();
       } catch (Exception e) {
           e.printStackTrace();
       }
       return new Address(evidenceSignersData.getContractAddress());
	        
}
 
Example #6
Source File: EvidenceVerify.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
public void insertEvidence(
        String evi,
        String info,
        String id,
        String signAddr,
        byte[] message,
        BigInteger v,
        byte[] r,
        byte[] s,
        TransactionSucCallback callback) {
    final Function function =
            new Function(
                    FUNC_INSERTEVIDENCE,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(evi),
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(info),
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(id),
                            new org.fisco.bcos.web3j.abi.datatypes.Address(signAddr),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(message),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Uint8(v),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(r),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(s)),
                    Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}
 
Example #7
Source File: ContractController.java    From WeBASE-Node-Manager with Apache License 2.0 6 votes vote down vote up
/**
 * send transaction.
 */
@PostMapping(value = "/transaction")
@PreAuthorize(ConstantProperties.HAS_ROLE_ADMIN)
public BaseResponse sendTransaction(@RequestBody @Valid TransactionInputParam param,
    BindingResult result) throws NodeMgrException {
    checkBindResult(result);
    // 0x0000000000000000000000000000000000000000 address is invalid
    if (Address.DEFAULT.toString().equals(param.getContractAddress())) {
        throw new NodeMgrException(ConstantCode.CONTRACT_ADDRESS_INVALID);
    }
    Instant startTime = Instant.now();
    log.info("start sendTransaction startTime:{} param:{}", startTime.toEpochMilli(),
        JsonTools.toJSONString(param));
    BaseResponse baseResponse = new BaseResponse(ConstantCode.SUCCESS);
    Object transRsp = contractService.sendTransaction(param);
    baseResponse.setData(transRsp);
    log.info("end sendTransaction useTime:{} result:{}",
        Duration.between(startTime, Instant.now()).toMillis(), JsonTools.toJSONString(baseResponse));

    return baseResponse;
}
 
Example #8
Source File: ChainGovernance.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
public RemoteCall<Tuple2<Boolean, BigInteger>> queryCommitteeMemberWeight(String user) {
    final Function function =
            new Function(
                    FUNC_QUERYCOMMITTEEMEMBERWEIGHT,
                    Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Address(user)),
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<Bool>() {}, new TypeReference<Int256>() {}));
    return new RemoteCall<Tuple2<Boolean, BigInteger>>(
            new Callable<Tuple2<Boolean, BigInteger>>() {
                @Override
                public Tuple2<Boolean, BigInteger> call() throws Exception {
                    List<Type> results = executeCallMultipleValueReturn(function);
                    return new Tuple2<Boolean, BigInteger>(
                            (Boolean) results.get(0).getValue(),
                            (BigInteger) results.get(1).getValue());
                }
            });
}
 
Example #9
Source File: Topic.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
public Tuple2<String, String> getDelOperatorInput(TransactionReceipt transactionReceipt) {
    String data = transactionReceipt.getInput().substring(10);
    final Function function = new Function(FUNC_DELOPERATOR, 
            Arrays.<Type>asList(), 
            Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}, new TypeReference<Address>() {}));
    List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());;
    return new Tuple2<String, String>(

            (String) results.get(0).getValue(), 
            (String) results.get(1).getValue()
            );
}
 
Example #10
Source File: Topic.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> addTopicACL(String topicName, String ownerAddress) {
    final Function function = new Function(
            FUNC_ADDTOPICACL, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(topicName), 
            new org.fisco.bcos.web3j.abi.datatypes.Address(ownerAddress)), 
            Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #11
Source File: EventEncoderTest.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
@Test
public void testEventbuildMethodSignature7() {
    Event event =
            new Event(
                    "test7",
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<Uint256>() {},
                            new TypeReference<Address>() {},
                            new TypeReference<Utf8String>() {},
                            new TypeReference<DynamicArray<Uint256>>() {},
                            new TypeReference<StaticArray3<Uint256>>() {},
                            new TypeReference<DynamicArray<Utf8String>>() {},
                            new TypeReference<StaticArray3<Utf8String>>() {},
                            new TypeReference<DynamicArray<DynamicArray<Uint256>>>() {},
                            new TypeReference<DynamicArray<StaticArray3<Uint256>>>() {}));

    assertThat(
            EventEncoder.buildMethodSignature(event.getName(), event.getParameters()),
            is(
                    "test7(uint256,address,string,uint256[],uint256[3],string[],string[3],uint256[][],uint256[3][])"));

    assertThat(
            EventEncoder.encode(event),
            is("0x63c45f0c8793f28acf7f800281aaf63198c09afdef34c785429628237221a648"));

    assertThat(
            EventEncoder.buildEventSignature(
                    "test7(uint256,address,string,uint256[],uint256[3],string[],string[3],uint256[][],uint256[3][])"),
            is("0x63c45f0c8793f28acf7f800281aaf63198c09afdef34c785429628237221a648"));
}
 
Example #12
Source File: Permission.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public String grantWriteSeq(String contractAddr, String user) {
    final Function function =
            new Function(
                    FUNC_GRANTWRITE,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Address(contractAddr),
                            new org.fisco.bcos.web3j.abi.datatypes.Address(user)),
                    Collections.<TypeReference<?>>emptyList());
    return createTransactionSeq(function);
}
 
Example #13
Source File: Permission.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> revokeWrite(String contractAddr, String user) {
    final Function function =
            new Function(
                    FUNC_REVOKEWRITE,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Address(contractAddr),
                            new org.fisco.bcos.web3j.abi.datatypes.Address(user)),
                    Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #14
Source File: ContractLifeCyclePrecompiled.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public Tuple1<String> getFreezeInput(TransactionReceipt transactionReceipt) {
    String data = transactionReceipt.getInput().substring(10);
    final Function function =
            new Function(
                    FUNC_FREEZE,
                    Arrays.<Type>asList(),
                    Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
    List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());
    ;
    return new Tuple1<String>((String) results.get(0).getValue());
}
 
Example #15
Source File: ChainGovernance.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public Tuple1<String> getGrantCommitteeMemberInput(TransactionReceipt transactionReceipt) {
    String data = transactionReceipt.getInput().substring(10);
    final Function function =
            new Function(
                    FUNC_GRANTCOMMITTEEMEMBER,
                    Arrays.<Type>asList(),
                    Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
    List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());
    ;
    return new Tuple1<String>((String) results.get(0).getValue());
}
 
Example #16
Source File: ResultEntity.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public static Object typeToObject(Type type) {
    Object obj = null;
    if (type instanceof NumericType) { // uint int
        obj = ((NumericType) type).getValue();
    } else if (type instanceof Bool) { // bool
        obj = ((Bool) type).getValue();
    } else if (type instanceof Address) { // address
        obj = type.toString();
    } else if (type instanceof Bytes) { // bytes32
        obj = new String(((Bytes) type).getValue()).trim();
    } else if (type instanceof DynamicBytes) { // bytes
        obj = new String(((DynamicBytes) type).getValue()).trim();
    } else if (type instanceof Utf8String) { // string
        obj = ((Utf8String) type).getValue();
    } else if (type instanceof Array) { // T[] T[k]
        List<Object> r = new ArrayList<Object>();
        List l = ((Array) type).getValue();
        for (int i = 0; i < l.size(); ++i) {
            r.add(typeToObject((Type) l.get(i)));
        }

        obj = (Object) r;
    } else {
        obj = (Object) obj;
    }

    return obj;
}
 
Example #17
Source File: ContractLifeCyclePrecompiled.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public String freezeSeq(String addr) {
    final Function function =
            new Function(
                    FUNC_FREEZE,
                    Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Address(addr)),
                    Collections.<TypeReference<?>>emptyList());
    return createTransactionSeq(function);
}
 
Example #18
Source File: ContractLifeCyclePrecompiled.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> freeze(String addr) {
    final Function function =
            new Function(
                    FUNC_FREEZE,
                    Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Address(addr)),
                    Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #19
Source File: ChainGovernance.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public void revokeOperator(String user, TransactionSucCallback callback) {
    final Function function =
            new Function(
                    FUNC_REVOKEOPERATOR,
                    Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Address(user)),
                    Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}
 
Example #20
Source File: Permission.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public String revokeWriteSeq(String contractAddr, String user) {
    final Function function =
            new Function(
                    FUNC_REVOKEWRITE,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Address(contractAddr),
                            new org.fisco.bcos.web3j.abi.datatypes.Address(user)),
                    Collections.<TypeReference<?>>emptyList());
    return createTransactionSeq(function);
}
 
Example #21
Source File: Topic.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
public void delOperator(String topicName, String operatorAddress, TransactionSucCallback callback) {
    final Function function = new Function(
            FUNC_DELOPERATOR, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(topicName), 
            new org.fisco.bcos.web3j.abi.datatypes.Address(operatorAddress)), 
            Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}
 
Example #22
Source File: Topic.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> delOperator(String topicName, String operatorAddress) {
    final Function function = new Function(
            FUNC_DELOPERATOR, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(topicName), 
            new org.fisco.bcos.web3j.abi.datatypes.Address(operatorAddress)), 
            Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #23
Source File: Permission.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public void revokeWrite(String contractAddr, String user, TransactionSucCallback callback) {
    final Function function =
            new Function(
                    FUNC_REVOKEWRITE,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Address(contractAddr),
                            new org.fisco.bcos.web3j.abi.datatypes.Address(user)),
                    Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}
 
Example #24
Source File: Topic.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
public String addOperatorSeq(String topicName, String operatorAddress) {
    final Function function = new Function(
            FUNC_ADDOPERATOR, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(topicName), 
            new org.fisco.bcos.web3j.abi.datatypes.Address(operatorAddress)), 
            Collections.<TypeReference<?>>emptyList());
    return createTransactionSeq(function);
}
 
Example #25
Source File: ChainGovernance.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public String revokeOperatorSeq(String user) {
    final Function function =
            new Function(
                    FUNC_REVOKEOPERATOR,
                    Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Address(user)),
                    Collections.<TypeReference<?>>emptyList());
    return createTransactionSeq(function);
}
 
Example #26
Source File: ContractLifeCyclePrecompiled.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public void freeze(String addr, TransactionSucCallback callback) {
    final Function function =
            new Function(
                    FUNC_FREEZE,
                    Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Address(addr)),
                    Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}
 
Example #27
Source File: Topic.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> addOperator(String topicName, String operatorAddress) {
    final Function function = new Function(
            FUNC_ADDOPERATOR, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(topicName), 
            new org.fisco.bcos.web3j.abi.datatypes.Address(operatorAddress)), 
            Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #28
Source File: ContractLifeCyclePrecompiled.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> grantManager(String contractAddr, String userAddr) {
    final Function function =
            new Function(
                    FUNC_GRANTMANAGER,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Address(contractAddr),
                            new org.fisco.bcos.web3j.abi.datatypes.Address(userAddr)),
                    Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #29
Source File: ChainGovernance.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> freezeAccount(String account) {
    final Function function =
            new Function(
                    FUNC_FREEZEACCOUNT,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Address(account)),
                    Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #30
Source File: ChainGovernance.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public void grantOperator(String user, TransactionSucCallback callback) {
    final Function function =
            new Function(
                    FUNC_GRANTOPERATOR,
                    Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Address(user)),
                    Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}