Search in sources :

Example 56 with Type

use of org.fisco.bcos.web3j.abi.datatypes.Type in project web3sdk by FISCO-BCOS.

the class ContractLifeCyclePrecompiled method getUnfreezeInput.

public Tuple1<String> getUnfreezeInput(TransactionReceipt transactionReceipt) {
    String data = transactionReceipt.getInput().substring(10);
    final Function function = new Function(FUNC_UNFREEZE, 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());
}
Also used : Function(org.fisco.bcos.web3j.abi.datatypes.Function) Type(org.fisco.bcos.web3j.abi.datatypes.Type) Tuple1(org.fisco.bcos.web3j.tuples.generated.Tuple1) Utf8String(org.fisco.bcos.web3j.abi.datatypes.Utf8String) TypeReference(org.fisco.bcos.web3j.abi.TypeReference)

Example 57 with Type

use of org.fisco.bcos.web3j.abi.datatypes.Type in project web3sdk by FISCO-BCOS.

the class Permission method getGrantWriteOutput.

public Tuple1<BigInteger> getGrantWriteOutput(TransactionReceipt transactionReceipt) {
    String data = transactionReceipt.getOutput();
    final Function function = new Function(FUNC_GRANTWRITE, Arrays.<Type>asList(), Arrays.<TypeReference<?>>asList(new TypeReference<Int256>() {
    }));
    List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());
    ;
    return new Tuple1<BigInteger>((BigInteger) results.get(0).getValue());
}
Also used : Function(org.fisco.bcos.web3j.abi.datatypes.Function) Type(org.fisco.bcos.web3j.abi.datatypes.Type) EncryptType(org.fisco.bcos.web3j.crypto.EncryptType) Tuple1(org.fisco.bcos.web3j.tuples.generated.Tuple1) Utf8String(org.fisco.bcos.web3j.abi.datatypes.Utf8String) TypeReference(org.fisco.bcos.web3j.abi.TypeReference)

Example 58 with Type

use of org.fisco.bcos.web3j.abi.datatypes.Type in project web3sdk by FISCO-BCOS.

the class Permission method getRevokeWriteOutput.

public Tuple1<BigInteger> getRevokeWriteOutput(TransactionReceipt transactionReceipt) {
    String data = transactionReceipt.getOutput();
    final Function function = new Function(FUNC_REVOKEWRITE, Arrays.<Type>asList(), Arrays.<TypeReference<?>>asList(new TypeReference<Int256>() {
    }));
    List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());
    ;
    return new Tuple1<BigInteger>((BigInteger) results.get(0).getValue());
}
Also used : Function(org.fisco.bcos.web3j.abi.datatypes.Function) Type(org.fisco.bcos.web3j.abi.datatypes.Type) EncryptType(org.fisco.bcos.web3j.crypto.EncryptType) Tuple1(org.fisco.bcos.web3j.tuples.generated.Tuple1) Utf8String(org.fisco.bcos.web3j.abi.datatypes.Utf8String) TypeReference(org.fisco.bcos.web3j.abi.TypeReference)

Example 59 with Type

use of org.fisco.bcos.web3j.abi.datatypes.Type in project web3sdk by FISCO-BCOS.

the class CallContractTest method testAsyncCallContract.

private static void testAsyncCallContract(CallContract callContract, String address) {
    TransactionCallback callback = new TransactionCallback();
    TransactionReceipt receipt;
    callContract.asyncSendTransaction(callback, gasPrice, gasLimit, address, "setAndget", new Utf8String("hello world"), new Int256(10086));
    try {
        callback.semaphore.acquire(1);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        System.out.println(e.getLocalizedMessage());
    }
    receipt = callback.receipt;
    List<TypeReference<?>> referencesList = Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {
    }, new TypeReference<Int256>() {
    });
    List<Type> returnList1 = FunctionReturnDecoder.decode(receipt.getOutput(), Utils.convert(referencesList));
    System.out.println("async call setAndget: " + (String) returnList1.get(0).getValue() + ", " + (BigInteger) returnList1.get(1).getValue());
    callContract.asyncSendTransaction(callback, address, "setAndget", new Utf8String("hello world"), new Int256(10086));
    try {
        callback.semaphore.acquire(1);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        System.out.println(e.getLocalizedMessage());
    }
    receipt = callback.receipt;
    referencesList = Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {
    }, new TypeReference<Int256>() {
    });
    List<Type> returnList2 = FunctionReturnDecoder.decode(receipt.getOutput(), Utils.convert(referencesList));
    System.out.println("default async call setAndget: " + (String) returnList2.get(0).getValue() + ", " + (BigInteger) returnList2.get(1).getValue());
}
Also used : TransactionReceipt(org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt) Utf8String(org.fisco.bcos.web3j.abi.datatypes.Utf8String) Utf8String(org.fisco.bcos.web3j.abi.datatypes.Utf8String) Int256(org.fisco.bcos.web3j.abi.datatypes.generated.Int256) Type(org.fisco.bcos.web3j.abi.datatypes.Type) BigInteger(java.math.BigInteger) TypeReference(org.fisco.bcos.web3j.abi.TypeReference)

Aggregations

Type (org.fisco.bcos.web3j.abi.datatypes.Type)59 Utf8String (org.fisco.bcos.web3j.abi.datatypes.Utf8String)52 TypeReference (org.fisco.bcos.web3j.abi.TypeReference)46 Function (org.fisco.bcos.web3j.abi.datatypes.Function)42 Tuple1 (org.fisco.bcos.web3j.tuples.generated.Tuple1)26 DynamicBytes (org.fisco.bcos.web3j.abi.datatypes.DynamicBytes)16 NamedType (org.fisco.bcos.web3j.protocol.core.methods.response.AbiDefinition.NamedType)16 Bool (org.fisco.bcos.web3j.abi.datatypes.Bool)15 ArrayList (java.util.ArrayList)14 Address (org.fisco.bcos.web3j.abi.datatypes.Address)14 EncryptType (org.fisco.bcos.web3j.crypto.EncryptType)14 Int256 (org.fisco.bcos.web3j.abi.datatypes.generated.Int256)13 Bytes32 (org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32)11 Uint256 (org.fisco.bcos.web3j.abi.datatypes.generated.Uint256)11 Test (org.junit.Test)10 AbiDefinition (org.fisco.bcos.web3j.protocol.core.methods.response.AbiDefinition)9 List (java.util.List)8 Tuple2 (org.fisco.bcos.web3j.tuples.generated.Tuple2)7 DynamicArray (org.fisco.bcos.web3j.abi.datatypes.DynamicArray)6 Event (org.fisco.bcos.web3j.abi.datatypes.Event)6