Java Code Examples for org.web3j.abi.datatypes.generated.Uint256

The following examples show how to use org.web3j.abi.datatypes.generated.Uint256. These examples are extracted from open source projects. 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 Project: web3j   Author: web3j   File: TypeDecoderTest.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void multiDimArrays() throws Exception {
    byte[] bytes1d = new byte[] {1, 2, 3};
    byte[][] bytes2d = new byte[][] {bytes1d, bytes1d, bytes1d};
    final byte[][][] bytes3d = new byte[][][] {bytes2d, bytes2d, bytes2d};

    assertEquals(TypeDecoder.instantiateType("bytes", bytes1d), (new DynamicBytes(bytes1d)));

    Type twoDim = TypeDecoder.instantiateType("uint256[][3]", bytes2d);
    assertTrue(twoDim instanceof StaticArray3);
    StaticArray3<DynamicArray<Uint256>> staticArray3 =
            (StaticArray3<DynamicArray<Uint256>>) twoDim;
    assertEquals(staticArray3.getComponentType(), DynamicArray.class);
    DynamicArray<Uint256> row1 = staticArray3.getValue().get(1);
    assertEquals(row1.getValue().get(2), new Uint256(3));

    Type threeDim = TypeDecoder.instantiateType("uint256[][3][3]", bytes3d);
    assertTrue(threeDim instanceof StaticArray3);
    StaticArray3<StaticArray3<DynamicArray<Uint256>>> staticArray3StaticArray3 =
            (StaticArray3<StaticArray3<DynamicArray<Uint256>>>) threeDim;
    assertEquals(staticArray3StaticArray3.getComponentType(), StaticArray3.class);
    row1 = staticArray3StaticArray3.getValue().get(1).getValue().get(1);
    assertEquals(row1.getValue().get(1), (new Uint256(2)));
}
 
Example #2
Source Project: Android-Wallet-Token-ERC20   Author: EasyToken   File: TokenERC20.java    License: Apache License 2.0 6 votes vote down vote up
public Observable<TransferEventResponse> transferEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
    final Event event = new Event("Transfer", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}, new TypeReference<Address>() {}),
            Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
    EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
    filter.addSingleTopic(EventEncoder.encode(event));
    return web3j.ethLogObservable(filter).map(new Func1<Log, TransferEventResponse>() {
        @Override
        public TransferEventResponse call(Log log) {
            EventValues eventValues = extractEventParameters(event, log);
            TransferEventResponse typedResponse = new TransferEventResponse();
            typedResponse.from = (String) eventValues.getIndexedValues().get(0).getValue();
            typedResponse.to = (String) eventValues.getIndexedValues().get(1).getValue();
            typedResponse.value = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
            return typedResponse;
        }
    });
}
 
Example #3
Source Project: web3j   Author: web3j   File: FunctionReturnDecoderTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void testDecodeStaticArrayValue() {
    List<TypeReference<Type>> outputParameters = new ArrayList<>(1);
    outputParameters.add(
            (TypeReference)
                    new TypeReference.StaticArrayTypeReference<StaticArray<Uint256>>(2) {});
    outputParameters.add((TypeReference) new TypeReference<Uint256>() {});

    List<Type> decoded =
            FunctionReturnDecoder.decode(
                    "0x0000000000000000000000000000000000000000000000000000000000000037"
                            + "0000000000000000000000000000000000000000000000000000000000000001"
                            + "000000000000000000000000000000000000000000000000000000000000000a",
                    outputParameters);

    StaticArray2<Uint256> uint256StaticArray2 =
            new StaticArray2<>(
                    new Uint256(BigInteger.valueOf(55)), new Uint256(BigInteger.ONE));

    List<Type> expected = Arrays.asList(uint256StaticArray2, new Uint256(BigInteger.TEN));
    assertEquals(decoded, (expected));
}
 
Example #4
Source Project: web3j   Author: web3j   File: Arrays.java    License: Apache License 2.0 6 votes vote down vote up
public RemoteFunctionCall<List> dynamicReverse(List<BigInteger> input) {
    final Function function = new Function(FUNC_DYNAMICREVERSE, 
            java.util.Arrays.<Type>asList(new org.web3j.abi.datatypes.DynamicArray<org.web3j.abi.datatypes.generated.Uint256>(
                    org.web3j.abi.datatypes.generated.Uint256.class,
                    org.web3j.abi.Utils.typeMap(input, org.web3j.abi.datatypes.generated.Uint256.class))), 
            java.util.Arrays.<TypeReference<?>>asList(new TypeReference<DynamicArray<Uint256>>() {}));
    return new RemoteFunctionCall<List>(function,
            new Callable<List>() {
                @Override
                @SuppressWarnings("unchecked")
                public List call() throws Exception {
                    List<Type> result = (List<Type>) executeCallSingleValueReturn(function, List.class);
                    return convertToNative(result);
                }
            });
}
 
Example #5
Source Project: web3j   Author: web3j   File: ContractTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testProcessEvent() {
    TransactionReceipt transactionReceipt = new TransactionReceipt();
    Log log = new Log();
    log.setTopics(
            Arrays.asList(
                    // encoded function
                    "0xfceb437c298f40d64702ac26411b2316e79f3c28ffa60edfc891ad4fc8ab82ca",
                    // indexed value
                    "0000000000000000000000003d6cb163f7c72d20b0fcd6baae5889329d138a4a"));
    // non-indexed value
    log.setData("0000000000000000000000000000000000000000000000000000000000000001");

    transactionReceipt.setLogs(singletonList(log));

    EventValues eventValues = contract.processEvent(transactionReceipt).get(0);

    assertEquals(
            singletonList(new Address("0x3d6cb163f7c72d20b0fcd6baae5889329d138a4a")),
            eventValues.getIndexedValues());
    assertEquals(singletonList(new Uint256(BigInteger.ONE)), eventValues.getNonIndexedValues());
}
 
Example #6
Source Project: web3j   Author: web3j   File: Arrays.java    License: Apache License 2.0 6 votes vote down vote up
public RemoteFunctionCall<List> multiFixed(List<List<BigInteger>> input) {
    final Function function = new Function(FUNC_MULTIFIXED, 
            java.util.Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.StaticArray6<org.web3j.abi.datatypes.generated.StaticArray2>(
                    org.web3j.abi.datatypes.generated.StaticArray2.class,
                    org.web3j.abi.Utils.typeMap(input, org.web3j.abi.datatypes.generated.StaticArray2.class,
            org.web3j.abi.datatypes.generated.Uint256.class))), 
            java.util.Arrays.<TypeReference<?>>asList(new TypeReference<DynamicArray<Uint256>>() {}));
    return new RemoteFunctionCall<List>(function,
            new Callable<List>() {
                @Override
                @SuppressWarnings("unchecked")
                public List call() throws Exception {
                    List<Type> result = (List<Type>) executeCallSingleValueReturn(function, List.class);
                    return convertToNative(result);
                }
            });
}
 
Example #7
Source Project: etherscan-explorer   Author: bing-chou   File: PublicResolver.java    License: GNU General Public License v3.0 6 votes vote down vote up
public RemoteCall<Tuple2<BigInteger, byte[]>> ABI(byte[] node, BigInteger contentTypes) {
    final Function function = new Function("ABI",
            Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Bytes32(node),
            new org.web3j.abi.datatypes.generated.Uint256(contentTypes)),
            Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}, new TypeReference<DynamicBytes>() {}));
    return new RemoteCall<Tuple2<BigInteger, byte[]>>(
            new Callable<Tuple2<BigInteger, byte[]>>() {
                @Override
                public Tuple2<BigInteger, byte[]> call() throws Exception {
                    List<Type> results = executeCallMultipleValueReturn(function);;
                    return new Tuple2<BigInteger, byte[]>(
                            (BigInteger) results.get(0).getValue(),
                            (byte[]) results.get(1).getValue());
                }
            });
}
 
Example #8
Source Project: web3j   Author: web3j   File: Arrays.java    License: Apache License 2.0 6 votes vote down vote up
public RemoteFunctionCall<List> multiDynamic(List<List<BigInteger>> input) {
    final Function function = new Function(FUNC_MULTIDYNAMIC, 
            java.util.Arrays.<Type>asList(new org.web3j.abi.datatypes.DynamicArray<org.web3j.abi.datatypes.generated.StaticArray2>(
                    org.web3j.abi.datatypes.generated.StaticArray2.class,
                    org.web3j.abi.Utils.typeMap(input, org.web3j.abi.datatypes.generated.StaticArray2.class,
            org.web3j.abi.datatypes.generated.Uint256.class))), 
            java.util.Arrays.<TypeReference<?>>asList(new TypeReference<DynamicArray<Uint256>>() {}));
    return new RemoteFunctionCall<List>(function,
            new Callable<List>() {
                @Override
                @SuppressWarnings("unchecked")
                public List call() throws Exception {
                    List<Type> result = (List<Type>) executeCallSingleValueReturn(function, List.class);
                    return convertToNative(result);
                }
            });
}
 
Example #9
Source Project: etherscan-explorer   Author: bing-chou   File: PublicResolver.java    License: GNU General Public License v3.0 6 votes vote down vote up
public Observable<ABIChangedEventResponse> aBIChangedEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
    final Event event = new Event("ABIChanged", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>() {}, new TypeReference<Uint256>() {}),
            Arrays.<TypeReference<?>>asList());
    EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
    filter.addSingleTopic(EventEncoder.encode(event));
    return web3j.ethLogObservable(filter).map(new Func1<Log, ABIChangedEventResponse>() {
        @Override
        public ABIChangedEventResponse call(Log log) {
            EventValues eventValues = extractEventParameters(event, log);
            ABIChangedEventResponse typedResponse = new ABIChangedEventResponse();
            typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue();
            typedResponse.contentType = (BigInteger) eventValues.getIndexedValues().get(1).getValue();
            return typedResponse;
        }
    });
}
 
Example #10
Source Project: etherscan-explorer   Author: bing-chou   File: FunctionWrappersIT.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testFibonacciNotify() throws Exception {
    Fibonacci fibonacci = Fibonacci.load(
            "0x3c05b2564139fb55820b18b72e94b2178eaace7d", Web3j.build(new HttpService()),
            ALICE, GAS_PRICE, GAS_LIMIT);

    TransactionReceipt transactionReceipt = fibonacci.fibonacciNotify(
            BigInteger.valueOf(15)).send();

    Fibonacci.NotifyEventResponse result = fibonacci.getNotifyEvents(transactionReceipt).get(0);

    assertThat(result.input,
            equalTo(new Uint256(BigInteger.valueOf(15))));

    assertThat(result.result,
            equalTo(new Uint256(BigInteger.valueOf(610))));
}
 
Example #11
Source Project: web3j   Author: web3j   File: HumanStandardTokenIT.java    License: Apache License 2.0 5 votes vote down vote up
private void sendApproveTransaction(
        Credentials credentials, String spender, BigInteger value, String contractAddress)
        throws Exception {
    Function function = approve(spender, value);
    String functionHash = execute(credentials, function, contractAddress);

    TransactionReceipt transferTransactionReceipt = waitForTransactionReceipt(functionHash);
    assertEquals(transferTransactionReceipt.getTransactionHash(), (functionHash));

    List<Log> logs = transferTransactionReceipt.getLogs();
    assertFalse(logs.isEmpty());
    Log log = logs.get(0);

    // verify the event was called with the function parameters
    List<String> topics = log.getTopics();
    assertEquals(topics.size(), (3));

    // event Transfer(address indexed _from, address indexed _to, uint256 _value);
    Event event = approvalEvent();

    // check function signature - we only have a single topic our event signature,
    // there are no indexed parameters in this example
    String encodedEventSignature = EventEncoder.encode(event);
    assertEquals(topics.get(0), (encodedEventSignature));
    assertEquals(new Address(topics.get(1)), (new Address(credentials.getAddress())));
    assertEquals(new Address(topics.get(2)), (new Address(spender)));

    // verify our two event parameters
    List<Type> results =
            FunctionReturnDecoder.decode(log.getData(), event.getNonIndexedParameters());
    assertEquals(results, (Collections.singletonList(new Uint256(value))));
}
 
Example #12
Source Project: web3j   Author: web3j   File: AbiV2TestFixture.java    License: Apache License 2.0 5 votes vote down vote up
public Boz(BigInteger data, String id) {
    super(
            new org.web3j.abi.datatypes.generated.Uint256(data),
            new org.web3j.abi.datatypes.Utf8String(id));
    this.data = data;
    this.id = id;
}
 
Example #13
Source Project: web3j   Author: web3j   File: EthCallIT.java    License: Apache License 2.0 5 votes vote down vote up
private EthCall ethCall(BigInteger value) throws java.io.IOException {
    final Function function =
            new Function(
                    Revert.FUNC_SET,
                    Collections.singletonList(new Uint256(value)),
                    Collections.emptyList());
    String encodedFunction = FunctionEncoder.encode(function);

    return web3j.ethCall(
                    Transaction.createEthCallTransaction(
                            ALICE.getAddress(), contract.getContractAddress(), encodedFunction),
                    DefaultBlockParameterName.LATEST)
            .send();
}
 
Example #14
Source Project: besu   Author: hyperledger   File: SimpleStorage.java    License: Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> set(final BigInteger value) {
  final Function function =
      new Function(
          FUNC_SET,
          Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(value)),
          Collections.<TypeReference<?>>emptyList());
  return executeRemoteCallTransaction(function);
}
 
Example #15
Source Project: web3j   Author: web3j   File: StructuredData.java    License: Apache License 2.0 5 votes vote down vote up
@JsonCreator
public EIP712Domain(
        @JsonProperty(value = "name") String name,
        @JsonProperty(value = "version") String version,
        @JsonProperty(value = "chainId") Uint256 chainId,
        @JsonProperty(value = "verifyingContract") Address verifyingContract) {
    this.name = name;
    this.version = version;
    this.chainId = chainId;
    this.verifyingContract = verifyingContract;
}
 
Example #16
Source Project: etherscan-explorer   Author: bing-chou   File: SolidityFunctionWrapperTest.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testBuildTypeName() {
    assertThat(buildTypeName("uint256"),
            is(ClassName.get(Uint256.class)));
    assertThat(buildTypeName("uint64"),
            is(ClassName.get(Uint64.class)));
    assertThat(buildTypeName("string"),
            is(ClassName.get(Utf8String.class)));

    assertThat(buildTypeName("uint256[]"),
            is(ParameterizedTypeName.get(DynamicArray.class, Uint256.class)));

    assertThat(buildTypeName("uint256[] storage"),
            is(ParameterizedTypeName.get(DynamicArray.class, Uint256.class)));

    assertThat(buildTypeName("uint256[] memory"),
            is(ParameterizedTypeName.get(DynamicArray.class, Uint256.class)));

    assertThat(buildTypeName("uint256[10]"),
            is(ParameterizedTypeName.get(StaticArray10.class, Uint256.class)));

    assertThat(buildTypeName("uint256[33]"),
            is(ParameterizedTypeName.get(StaticArray.class, Uint256.class)));

    assertThat(buildTypeName("uint256[10][3]"),
            is(ParameterizedTypeName.get(ClassName.get(StaticArray3.class),
                    ParameterizedTypeName.get(StaticArray10.class, Uint256.class))));

    assertThat(buildTypeName("uint256[2][]"),
            is(ParameterizedTypeName.get(ClassName.get(DynamicArray.class),
                    ParameterizedTypeName.get(StaticArray2.class, Uint256.class))));

    assertThat(buildTypeName("uint256[33][]"),
            is(ParameterizedTypeName.get(ClassName.get(DynamicArray.class),
                    ParameterizedTypeName.get(StaticArray.class, Uint256.class))));

    assertThat(buildTypeName("uint256[][]"),
            is(ParameterizedTypeName.get(ClassName.get(DynamicArray.class),
                    ParameterizedTypeName.get(DynamicArray.class, Uint256.class))));
}
 
Example #17
Source Project: Upchain-wallet   Author: xilibi2003   File: TokenRepository.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public static String createTokenTransferData(String to, BigInteger tokenAmount) {
        List<Type> params = Arrays.<Type>asList(new Address(to), new Uint256(tokenAmount));

        List<TypeReference<?>> returnTypes = Arrays.<TypeReference<?>>asList(new TypeReference<Bool>() {
        });

        Function function = new Function("transfer", params, returnTypes);
        return FunctionEncoder.encode(function);
//        return Numeric.hexStringToByteArray(Numeric.cleanHexPrefix(encodedFunction));
    }
 
Example #18
Source Project: etherscan-explorer   Author: bing-chou   File: FunctionReturnDecoderTest.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testDecodeIndexedDynamicArrayValue() {
    DynamicArray<Uint256> array = new DynamicArray<>(new Uint256(BigInteger.TEN));
    String encoded = TypeEncoder.encodeDynamicArray(array);
    String hash = Hash.sha3(encoded);

    assertThat(FunctionReturnDecoder.decodeIndexedValue(
            hash,
            new TypeReference<DynamicArray>() {}),
            equalTo(new Bytes32(Numeric.hexStringToByteArray(hash))));
}
 
Example #19
Source Project: web3j   Author: web3j   File: HumanStandardToken.java    License: Apache License 2.0 5 votes vote down vote up
@Deprecated
public static RemoteCall<HumanStandardToken> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, BigInteger _initialAmount, String _tokenName, BigInteger _decimalUnits, String _tokenSymbol) {
    String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(_initialAmount),
            new org.web3j.abi.datatypes.Utf8String(_tokenName),
            new org.web3j.abi.datatypes.generated.Uint8(_decimalUnits),
            new org.web3j.abi.datatypes.Utf8String(_tokenSymbol)));
    return deployRemoteCall(HumanStandardToken.class, web3j, credentials, gasPrice, gasLimit, BINARY, encodedConstructor);
}
 
Example #20
Source Project: client-sdk-java   Author: PlatONnetwork   File: FunctionReturnDecoderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testDecodeIndexedDynamicArrayValue() {
    DynamicArray<Uint256> array = new DynamicArray<>(new Uint256(BigInteger.TEN));
    String encoded = TypeEncoder.encodeDynamicArray(array);
    String hash = Hash.sha3(encoded);

    assertThat(FunctionReturnDecoder.decodeIndexedValue(
            hash,
            new TypeReference<DynamicArray>() {}),
            equalTo(new Bytes32(Numeric.hexStringToByteArray(hash))));
}
 
Example #21
Source Project: client-sdk-java   Author: PlatONnetwork   File: UtilsTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testTypeMap() throws Exception {
    final List<BigInteger> input = Arrays.asList(
            BigInteger.ZERO, BigInteger.ONE, BigInteger.TEN);

    assertThat(typeMap(input, Uint256.class),
            equalTo(Arrays.asList(
                    new Uint256(BigInteger.ZERO),
                    new Uint256(BigInteger.ONE),
                    new Uint256(BigInteger.TEN))));
}
 
Example #22
Source Project: Android-Wallet-Token-ERC20   Author: EasyToken   File: TokenERC20.java    License: Apache License 2.0 5 votes vote down vote up
public static RemoteCall<TokenERC20> deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialSupply, String tokenName, String tokenSymbol, BigInteger tokendecimals) {
    String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(new Uint256(initialSupply),
            new Utf8String(tokenName),
            new Utf8String(tokenSymbol),
            new Uint8(tokendecimals)));
    return deployRemoteCall(TokenERC20.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, encodedConstructor);
}
 
Example #23
Source Project: etherscan-explorer   Author: bing-chou   File: ContractTest.java    License: GNU General Public License v3.0 5 votes vote down vote up
public RemoteCall<List<Type>> callMultipleValue()
        throws ExecutionException, InterruptedException {
    Function function = new Function("call",
            Arrays.<Type>asList(),
            Arrays.<TypeReference<?>>asList(
                    new TypeReference<Uint256>() { },
                    new TypeReference<Uint256>() { }));
    return executeRemoteCallMultipleValueReturn(function);
}
 
Example #24
Source Project: web3j   Author: web3j   File: HumanStandardTokenIT.java    License: Apache License 2.0 5 votes vote down vote up
private void sendTransferTokensTransaction(
        Credentials credentials, String to, String contractAddress, BigInteger qty)
        throws Exception {

    Function function = transfer(to, qty);
    String functionHash = execute(credentials, function, contractAddress);

    TransactionReceipt transferTransactionReceipt = waitForTransactionReceipt(functionHash);
    assertEquals(transferTransactionReceipt.getTransactionHash(), (functionHash));

    List<Log> logs = transferTransactionReceipt.getLogs();
    assertFalse(logs.isEmpty());
    Log log = logs.get(0);

    // verify the event was called with the function parameters
    List<String> topics = log.getTopics();
    assertEquals(topics.size(), (3));

    Event transferEvent = transferEvent();

    // check function signature - we only have a single topic our event signature,
    // there are no indexed parameters in this example
    String encodedEventSignature = EventEncoder.encode(transferEvent);
    assertEquals(topics.get(0), (encodedEventSignature));
    assertEquals(new Address(topics.get(1)), (new Address(credentials.getAddress())));
    assertEquals(new Address(topics.get(2)), (new Address(to)));

    // verify qty transferred
    List<Type> results =
            FunctionReturnDecoder.decode(
                    log.getData(), transferEvent.getNonIndexedParameters());
    assertEquals(results, (Collections.singletonList(new Uint256(qty))));
}
 
Example #25
Source Project: eventeum   Author: ConsenSys   File: EventEmitter.java    License: Apache License 2.0 5 votes vote down vote up
public RemoteFunctionCall<TransactionReceipt> emitEvent(byte[] value1, BigInteger value2, String value3) {
    final Function function = new Function(
            FUNC_EMITEVENT, 
            Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Bytes32(value1), 
            new org.web3j.abi.datatypes.generated.Uint256(value2), 
            new org.web3j.abi.datatypes.Utf8String(value3)), 
            Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #26
Source Project: Android-Wallet-Token-ERC20   Author: EasyToken   File: TokenERC20.java    License: Apache License 2.0 5 votes vote down vote up
public List<BurnEventResponse> getBurnEvents(TransactionReceipt transactionReceipt) {
    final Event event = new Event("Burn", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}),
            Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
    List<EventValues> valueList = extractEventParameters(event, transactionReceipt);
    ArrayList<BurnEventResponse> responses = new ArrayList<BurnEventResponse>(valueList.size());
    for (EventValues eventValues : valueList) {
        BurnEventResponse typedResponse = new BurnEventResponse();
        typedResponse.from = (String) eventValues.getIndexedValues().get(0).getValue();
        typedResponse.value = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
        responses.add(typedResponse);
    }
    return responses;
}
 
Example #27
Source Project: client-sdk-java   Author: PlatONnetwork   File: ContractTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testTransactionFailed() throws Exception {
    thrown.expect(TransactionException.class);
    thrown.expectMessage(
            "Transaction has failed with status: 0x0. Gas used: 1. (not-enough gas?)");

    TransactionReceipt transactionReceipt = new TransactionReceipt();
    transactionReceipt.setTransactionHash(TRANSACTION_HASH);
    transactionReceipt.setStatus("0x0");
    transactionReceipt.setGasUsed("0x1");

    prepareTransaction(transactionReceipt);
    contract.performTransaction(
            new Address(BigInteger.TEN), new Uint256(BigInteger.ONE)).send();
}
 
Example #28
Source Project: web3j   Author: web3j   File: ERC721.java    License: Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> transferFrom(String _from, String _to, BigInteger _tokenId, BigInteger weiValue) {
    final Function function = new Function(
            FUNC_TRANSFERFROM, 
            Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(_from), 
            new org.web3j.abi.datatypes.Address(_to), 
            new org.web3j.abi.datatypes.generated.Uint256(_tokenId)), 
            Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function, weiValue);
}
 
Example #29
Source Project: client-sdk-java   Author: PlatONnetwork   File: ContractTest.java    License: Apache License 2.0 5 votes vote down vote up
public RemoteCall<List<Type>> callMultipleValue()
        throws ExecutionException, InterruptedException {
    Function function = new Function("call",
            Arrays.<Type>asList(),
            Arrays.<TypeReference<?>>asList(
                    new TypeReference<Uint256>() { },
                    new TypeReference<Uint256>() { }));
    return executeRemoteCallMultipleValueReturn(function);
}
 
Example #30
Source Project: client-sdk-java   Author: PlatONnetwork   File: ContractTest.java    License: Apache License 2.0 5 votes vote down vote up
public List<EventValues> processEvent(TransactionReceipt transactionReceipt) {
    Event event = new Event("Event",
            Arrays.<TypeReference<?>>asList(
                    new TypeReference<Address>(true) { },
                    new TypeReference<Uint256>() { }));
    return extractEventParameters(event, transactionReceipt);
}