org.fisco.bcos.web3j.abi.datatypes.DynamicArray Java Examples
The following examples show how to use
org.fisco.bcos.web3j.abi.datatypes.DynamicArray.
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: TableTest.java From web3sdk with Apache License 2.0 | 6 votes |
public RemoteCall<Tuple3<List<String>, List<BigInteger>, List<String>>> select(String name) { final Function function = new Function( FUNC_SELECT, Arrays.<Type>asList( new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name)), Arrays.<TypeReference<?>>asList( new TypeReference<DynamicArray<Utf8String>>() {}, new TypeReference<DynamicArray<Int256>>() {}, new TypeReference<DynamicArray<Utf8String>>() {})); return new RemoteCall<Tuple3<List<String>, List<BigInteger>, List<String>>>( new Callable<Tuple3<List<String>, List<BigInteger>, List<String>>>() { @Override public Tuple3<List<String>, List<BigInteger>, List<String>> call() throws Exception { List<Type> results = executeCallMultipleValueReturn(function); return new Tuple3<List<String>, List<BigInteger>, List<String>>( convertToNative((List<Utf8String>) results.get(0).getValue()), convertToNative((List<Int256>) results.get(1).getValue()), convertToNative((List<Utf8String>) results.get(2).getValue())); } }); }
Example #2
Source File: ContractLifeCyclePrecompiled.java From web3sdk with Apache License 2.0 | 6 votes |
public RemoteCall<Tuple2<BigInteger, List<String>>> listManager(String addr) { final Function function = new Function( FUNC_LISTMANAGER, Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Address(addr)), Arrays.<TypeReference<?>>asList( new TypeReference<Int256>() {}, new TypeReference<DynamicArray<Address>>() {})); return new RemoteCall<Tuple2<BigInteger, List<String>>>( new Callable<Tuple2<BigInteger, List<String>>>() { @Override public Tuple2<BigInteger, List<String>> call() throws Exception { List<Type> results = executeCallMultipleValueReturn(function); return new Tuple2<BigInteger, List<String>>( (BigInteger) results.get(0).getValue(), convertToNative((List<Address>) results.get(1).getValue())); } }); }
Example #3
Source File: TypeDecoder.java From web3sdk with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public static <T extends Type> T decodeDynamicArray( String input, int offset, java.lang.reflect.Type type) { int length = decodeUintAsInt(input, offset); BiFunction<List<T>, String, T> function = (elements, typeName) -> { if (elements.isEmpty()) { return (T) DynamicArray.empty(typeName); } else { return (T) new DynamicArray<>(elements); } }; int valueOffset = offset + MAX_BYTE_LENGTH_FOR_HEX_STRING; return decodeArrayElements(input, valueOffset, type, length, function); }
Example #4
Source File: Topic.java From WeEvent with Apache License 2.0 | 6 votes |
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 #5
Source File: Topic.java From WeEvent with Apache License 2.0 | 6 votes |
public String flushSnapshotSeq(List<String> topicName, List<BigInteger> lastSequence, List<BigInteger> lastBlock, List<BigInteger> lastTimestamp, List<String> lastSender) { final Function function = new Function( FUNC_FLUSHSNAPSHOT, Arrays.<Type>asList(topicName.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("string[]"): new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.Utf8String>( org.fisco.bcos.web3j.abi.Utils.typeMap(topicName, org.fisco.bcos.web3j.abi.datatypes.Utf8String.class)), lastSequence.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"): new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>( org.fisco.bcos.web3j.abi.Utils.typeMap(lastSequence, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), lastBlock.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"): new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>( org.fisco.bcos.web3j.abi.Utils.typeMap(lastBlock, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), lastTimestamp.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"): new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>( org.fisco.bcos.web3j.abi.Utils.typeMap(lastTimestamp, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), lastSender.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("address[]"): new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.Address>( org.fisco.bcos.web3j.abi.Utils.typeMap(lastSender, org.fisco.bcos.web3j.abi.datatypes.Address.class))), Collections.<TypeReference<?>>emptyList()); return createTransactionSeq(function); }
Example #6
Source File: Topic.java From WeEvent with Apache License 2.0 | 6 votes |
public void flushSnapshot(List<String> topicName, List<BigInteger> lastSequence, List<BigInteger> lastBlock, List<BigInteger> lastTimestamp, List<String> lastSender, TransactionSucCallback callback) { final Function function = new Function( FUNC_FLUSHSNAPSHOT, Arrays.<Type>asList(topicName.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("string[]"): new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.Utf8String>( org.fisco.bcos.web3j.abi.Utils.typeMap(topicName, org.fisco.bcos.web3j.abi.datatypes.Utf8String.class)), lastSequence.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"): new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>( org.fisco.bcos.web3j.abi.Utils.typeMap(lastSequence, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), lastBlock.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"): new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>( org.fisco.bcos.web3j.abi.Utils.typeMap(lastBlock, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), lastTimestamp.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"): new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>( org.fisco.bcos.web3j.abi.Utils.typeMap(lastTimestamp, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), lastSender.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("address[]"): new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.Address>( org.fisco.bcos.web3j.abi.Utils.typeMap(lastSender, org.fisco.bcos.web3j.abi.datatypes.Address.class))), Collections.<TypeReference<?>>emptyList()); asyncExecuteTransaction(function, callback); }
Example #7
Source File: Topic.java From WeEvent with Apache License 2.0 | 6 votes |
public RemoteCall<TransactionReceipt> flushSnapshot(List<String> topicName, List<BigInteger> lastSequence, List<BigInteger> lastBlock, List<BigInteger> lastTimestamp, List<String> lastSender) { final Function function = new Function( FUNC_FLUSHSNAPSHOT, Arrays.<Type>asList(topicName.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("string[]"): new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.Utf8String>( org.fisco.bcos.web3j.abi.Utils.typeMap(topicName, org.fisco.bcos.web3j.abi.datatypes.Utf8String.class)), lastSequence.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"): new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>( org.fisco.bcos.web3j.abi.Utils.typeMap(lastSequence, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), lastBlock.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"): new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>( org.fisco.bcos.web3j.abi.Utils.typeMap(lastBlock, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), lastTimestamp.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"): new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>( org.fisco.bcos.web3j.abi.Utils.typeMap(lastTimestamp, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), lastSender.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("address[]"): new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.Address>( org.fisco.bcos.web3j.abi.Utils.typeMap(lastSender, org.fisco.bcos.web3j.abi.datatypes.Address.class))), Collections.<TypeReference<?>>emptyList()); return executeRemoteCallTransaction(function); }
Example #8
Source File: Utils.java From web3sdk with Apache License 2.0 | 6 votes |
@SuppressWarnings("rawtypes") public static <T extends Type> boolean dynamicType(java.lang.reflect.Type type) throws ClassNotFoundException { Class<T> cls = Utils.getClassType(type); // dynamic type if (Utf8String.class.isAssignableFrom(cls) || DynamicBytes.class.isAssignableFrom(cls) || DynamicArray.class.isAssignableFrom(cls)) { return true; } // not static type if (!StaticArray.class.isAssignableFrom(cls)) { return false; } // unpack static array for checking if dynamic type java.lang.reflect.Type[] types = ((ParameterizedType) type).getActualTypeArguments(); return dynamicType(types[0]); }
Example #9
Source File: MixContract.java From web3sdk with Apache License 2.0 | 6 votes |
public RemoteCall<Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>> read(String name) { final Function function = new Function( FUNC_READ, Arrays.<Type>asList( new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name)), Arrays.<TypeReference<?>>asList( new TypeReference<DynamicArray<Bytes32>>() {}, new TypeReference<DynamicArray<Int256>>() {}, new TypeReference<DynamicArray<Bytes32>>() {})); return new RemoteCall<Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>>( new Callable<Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>>() { @Override public Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>> call() throws Exception { List<Type> results = executeCallMultipleValueReturn(function); return new Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>( convertToNative((List<Bytes32>) results.get(0).getValue()), convertToNative((List<Int256>) results.get(1).getValue()), convertToNative((List<Bytes32>) results.get(2).getValue())); } }); }
Example #10
Source File: TableTest.java From web3sdk with Apache License 2.0 | 6 votes |
public RemoteCall<Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>> select(String name) { final Function function = new Function( FUNC_SELECT, Arrays.<Type>asList( new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name)), Arrays.<TypeReference<?>>asList( new TypeReference<DynamicArray<Bytes32>>() {}, new TypeReference<DynamicArray<Int256>>() {}, new TypeReference<DynamicArray<Bytes32>>() {})); return new RemoteCall<Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>>( new Callable<Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>>() { @Override public Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>> call() throws Exception { List<Type> results = executeCallMultipleValueReturn(function); return new Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>( convertToNative((List<Bytes32>) results.get(0).getValue()), convertToNative((List<Int256>) results.get(1).getValue()), convertToNative((List<Bytes32>) results.get(2).getValue())); } }); }
Example #11
Source File: TableTest.java From web3sdk with Apache License 2.0 | 6 votes |
public RemoteCall<Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>> select(String name) { final Function function = new Function( FUNC_SELECT, Arrays.<Type>asList( new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name)), Arrays.<TypeReference<?>>asList( new TypeReference<DynamicArray<Bytes32>>() {}, new TypeReference<DynamicArray<Int256>>() {}, new TypeReference<DynamicArray<Bytes32>>() {})); return new RemoteCall<Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>>( new Callable<Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>>() { @Override public Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>> call() throws Exception { List<Type> results = executeCallMultipleValueReturn(function); return new Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>( convertToNative((List<Bytes32>) results.get(0).getValue()), convertToNative((List<Int256>) results.get(1).getValue()), convertToNative((List<Bytes32>) results.get(2).getValue())); } }); }
Example #12
Source File: TopicController.java From WeEvent with Apache License 2.0 | 6 votes |
public RemoteCall<Tuple3<BigInteger, BigInteger, List<String>>> listTopicName(BigInteger pageIndex, BigInteger pageSize) { final Function function = new Function(FUNC_LISTTOPICNAME, Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.generated.Uint256(pageIndex), new org.fisco.bcos.web3j.abi.datatypes.generated.Uint256(pageSize)), Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}, new TypeReference<Uint256>() {}, new TypeReference<DynamicArray<Utf8String>>() {})); return new RemoteCall<Tuple3<BigInteger, BigInteger, List<String>>>( new Callable<Tuple3<BigInteger, BigInteger, List<String>>>() { @Override public Tuple3<BigInteger, BigInteger, List<String>> call() throws Exception { List<Type> results = executeCallMultipleValueReturn(function); return new Tuple3<BigInteger, BigInteger, List<String>>( (BigInteger) results.get(0).getValue(), (BigInteger) results.get(1).getValue(), convertToNative((List<Utf8String>) results.get(2).getValue())); } }); }
Example #13
Source File: EventEncoderTest.java From web3sdk with Apache License 2.0 | 6 votes |
@Test public void testEventbuildMethodSignature0() { Event event = new Event( "g", Arrays.<TypeReference<?>>asList( new TypeReference<DynamicArray<DynamicArray<Uint256>>>() {}, new TypeReference<DynamicArray<Utf8String>>() {})); assertThat( EventEncoder.buildMethodSignature(event.getName(), event.getParameters()), is("g(uint256[][],string[])")); assertThat( EventEncoder.encode(event), is("0x2289b18cd8c6e198648b35d3bcf2ff8668984543f01927711c161bcf7b5e1bba")); assertThat( EventEncoder.buildEventSignature("g(uint256[][],string[])"), is("0x2289b18cd8c6e198648b35d3bcf2ff8668984543f01927711c161bcf7b5e1bba")); }
Example #14
Source File: EventEncoderTest.java From web3sdk with Apache License 2.0 | 6 votes |
@Test public void testEventbuildMethodSignature1() { Event event = new Event( "f", Arrays.<TypeReference<?>>asList( new TypeReference<Uint>() {}, new TypeReference<DynamicArray<Uint32>>() {}, new TypeReference<Bytes10>() {}, new TypeReference<DynamicBytes>() {})); assertThat( EventEncoder.buildMethodSignature(event.getName(), event.getParameters()), is("f(uint256,uint32[],bytes10,bytes)")); assertThat( EventEncoder.encode(event), is("0x8be652465888a0c5d65fc9d0a7e898b9ca98de97185c53a54ec408fd2fd5d45d")); assertThat( EventEncoder.buildEventSignature("f(uint256,uint32[],bytes10,bytes)"), is("0x8be652465888a0c5d65fc9d0a7e898b9ca98de97185c53a54ec408fd2fd5d45d")); }
Example #15
Source File: EventEncoderTest.java From web3sdk with Apache License 2.0 | 6 votes |
@Test public void testEventbuildMethodSignature2() { Event event = new Event( "f", Arrays.<TypeReference<?>>asList( new TypeReference<DynamicBytes>() {}, new TypeReference<Bool>() {}, new TypeReference<DynamicArray<Uint256>>() {})); assertThat( EventEncoder.buildMethodSignature(event.getName(), event.getParameters()), is("f(bytes,bool,uint256[])")); assertThat( EventEncoder.encode(event), is("0xa83b3f0112fa8ecc02937d734929bbaa30731fe27b20195418852fb64ac2837d")); assertThat( EventEncoder.buildEventSignature("f(bytes,bool,uint256[])"), is("0xa83b3f0112fa8ecc02937d734929bbaa30731fe27b20195418852fb64ac2837d")); }
Example #16
Source File: EventEncoderTest.java From web3sdk with Apache License 2.0 | 6 votes |
@Test public void testEventbuildMethodSignature5() { Event event = new Event( "test5", Arrays.<TypeReference<?>>asList( new TypeReference< DynamicArray< DynamicArray< DynamicArray< DynamicArray<Utf8String>>>>>() {})); assertThat( EventEncoder.buildMethodSignature(event.getName(), event.getParameters()), is("test5(string[][][][])")); assertThat( EventEncoder.encode(event), is("0x69f175db6ba77ff81ba5e31ca58ddfeb6b2ea420d1233fba18371dc63a12e9c1")); assertThat( EventEncoder.buildEventSignature("test5(string[][][][])"), is("0x69f175db6ba77ff81ba5e31ca58ddfeb6b2ea420d1233fba18371dc63a12e9c1")); }
Example #17
Source File: EventEncoderTest.java From web3sdk with Apache License 2.0 | 6 votes |
@Test public void testEventbuildMethodSignature6() { Event event = new Event( "test6", Arrays.<TypeReference<?>>asList( new TypeReference<Uint256>() {}, new TypeReference<Int256>() {}, new TypeReference<Utf8String>() {}, new TypeReference<DynamicArray<Utf8String>>() {}, new TypeReference<StaticArray3<Utf8String>>() {})); assertThat( EventEncoder.buildMethodSignature(event.getName(), event.getParameters()), is("test6(uint256,int256,string,string[],string[3])")); assertThat( EventEncoder.encode(event), is("0x5199068657caa55d23ad866ba738a7f21e567e6f50aa8173ac108efdd5d3bb79")); assertThat( EventEncoder.buildEventSignature("test6(uint256,int256,string,string[],string[3])"), is("0x5199068657caa55d23ad866ba738a7f21e567e6f50aa8173ac108efdd5d3bb79")); }
Example #18
Source File: Evidence.java From WeBASE-Front with Apache License 2.0 | 6 votes |
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 #19
Source File: EventEncoderTest.java From web3sdk with Apache License 2.0 | 6 votes |
@Test public void testEventbuildMethodSignature9() { Event event = new Event( "test9", Arrays.<TypeReference<?>>asList( new TypeReference<Utf8String>() {}, new TypeReference<Uint256>() {}, new TypeReference<StaticArray6<Uint256>>() {}, new TypeReference<DynamicArray<Uint256>>() {}, new TypeReference<Bool>() {}, new TypeReference<Address>() {})); assertThat( EventEncoder.buildMethodSignature(event.getName(), event.getParameters()), is("test9(string,uint256,uint256[6],uint256[],bool,address)")); assertThat( EventEncoder.encode(event), is("0xa37d8a63087cf5837e0b9ff13d07d756479f8afdfe4b05ea3dfdc98154ef58ed")); assertThat( EventEncoder.buildEventSignature( "test9(string,uint256,uint256[6],uint256[],bool,address)"), is("0xa37d8a63087cf5837e0b9ff13d07d756479f8afdfe4b05ea3dfdc98154ef58ed")); }
Example #20
Source File: EventEncoderTest.java From web3sdk with Apache License 2.0 | 6 votes |
@Test public void testEventbuildMethodSignature10() { Event event = new Event( "test10", Arrays.<TypeReference<?>>asList( new TypeReference<DynamicArray<Utf8String>>() {})); assertThat( EventEncoder.buildMethodSignature(event.getName(), event.getParameters()), is("test10(string[])")); assertThat( EventEncoder.encode(event), is("0xfb9fe4911c195fb1112aaa9c3ac5a54a0c521f8cb0f4ee9290a9bff28542d051")); assertThat( EventEncoder.buildEventSignature("test10(string[])"), is("0xfb9fe4911c195fb1112aaa9c3ac5a54a0c521f8cb0f4ee9290a9bff28542d051")); }
Example #21
Source File: Evidence.java From evidenceSample with Apache License 2.0 | 6 votes |
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 #22
Source File: FunctionReturnDecoder.java From web3sdk with Apache License 2.0 | 5 votes |
private static List<Type> build(String input, List<TypeReference<Type>> outputParameters) { List<Type> results = new ArrayList<>(outputParameters.size()); int offset = 0; for (TypeReference<?> typeReference : outputParameters) { try { @SuppressWarnings("unchecked") Class<Type> cls = (Class<Type>) typeReference.getClassType(); int hexStringDataOffset = getDataOffset(input, offset, typeReference.getType()); Type result; if (DynamicArray.class.isAssignableFrom(cls)) { result = TypeDecoder.decodeDynamicArray( input, hexStringDataOffset, typeReference.getType()); } else if (StaticArray.class.isAssignableFrom(cls)) { int length = Integer.parseInt( cls.getSimpleName() .substring(StaticArray.class.getSimpleName().length())); result = TypeDecoder.decodeStaticArray( input, hexStringDataOffset, typeReference.getType(), length); } else { result = TypeDecoder.decode(input, hexStringDataOffset, cls); } results.add(result); offset += Utils.getOffset(typeReference.getType()) * TypeDecoder.MAX_BYTE_LENGTH_FOR_HEX_STRING; } catch (ClassNotFoundException e) { throw new UnsupportedOperationException("Invalid class reference provided", e); } } return results; }
Example #23
Source File: EventEncoderTest.java From web3sdk with Apache License 2.0 | 5 votes |
@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 #24
Source File: EvidenceSignersData.java From evidenceSample with Apache License 2.0 | 5 votes |
public RemoteCall<List> getSigners() { final Function function = new Function(FUNC_GETSIGNERS, Arrays.<Type>asList(), Arrays.<TypeReference<?>>asList(new TypeReference<DynamicArray<Address>>() {})); return new RemoteCall<List>( new Callable<List>() { @Override @SuppressWarnings("unchecked") public List call() throws Exception { List<Type> result = (List<Type>) executeCallSingleValueReturn(function, List.class); return convertToNative(result); } }); }
Example #25
Source File: Utils.java From web3sdk with Apache License 2.0 | 5 votes |
private static <T extends Type, U extends Type> String getParameterizedTypeName( java.lang.reflect.Type type) { try { Class<?> cls = Utils.getClassType(type); if (DynamicArray.class.isAssignableFrom(cls)) { return getTypeName(((ParameterizedType) type).getActualTypeArguments()[0]) + "[]"; } else if (StaticArray.class.isAssignableFrom(cls)) { int length = Integer.parseInt( cls.getSimpleName() .substring(StaticArray.class.getSimpleName().length())); return getTypeName(((ParameterizedType) type).getActualTypeArguments()[0]) + "[" + length + "]"; } else { throw new UnsupportedOperationException("Invalid type provided " + cls.getName()); } } catch (ClassNotFoundException e) { throw new UnsupportedOperationException("Invalid class reference provided", e); } }
Example #26
Source File: AbiUtil.java From WeBASE-Front with Apache License 2.0 | 5 votes |
/** * input parameter format. * * @param funcInputTypes list * @param params list * @return */ public static List<Type> inputFormat(List<String> funcInputTypes, List<Object> params) throws FrontException { List<Type> finalInputs = new ArrayList<>(); for (int i = 0; i < funcInputTypes.size(); i++) { Class<? extends Type> inputType = null; Object input = null; if (funcInputTypes.get(i).contains("[") && funcInputTypes.get(i).contains("]")) { List<Object> arrList; try { arrList = (List<Object>) params.get(i); } catch (ClassCastException e) { log.error("params of index {} parse List error: {}", i, params.get(i)); throw new FrontException(ConstantCode.PARAM_ERROR); } List<Type> arrParams = new ArrayList<>(); for (int j = 0; j < arrList.size(); j++) { inputType = AbiTypes.getType( funcInputTypes.get(i).substring(0, funcInputTypes.get(i).indexOf("["))); input = ContractTypeUtil.parseByType( funcInputTypes.get(i).substring(0, funcInputTypes.get(i).indexOf("[")), arrList.get(j).toString()); arrParams.add(ContractTypeUtil.generateClassFromInput(input.toString(), inputType)); } finalInputs.add(new DynamicArray<>(arrParams)); } else { inputType = AbiTypes.getType(funcInputTypes.get(i)); input = ContractTypeUtil.parseByType(funcInputTypes.get(i), params.get(i).toString()); finalInputs.add(ContractTypeUtil.generateClassFromInput(input.toString(), inputType)); } } return finalInputs; }
Example #27
Source File: Evidence.java From evidenceSample with Apache License 2.0 | 5 votes |
public RemoteCall<List> getSigners() { final Function function = new Function(FUNC_GETSIGNERS, Arrays.<Type>asList(), Arrays.<TypeReference<?>>asList(new TypeReference<DynamicArray<Address>>() {})); return new RemoteCall<List>( new Callable<List>() { @Override @SuppressWarnings("unchecked") public List call() throws Exception { List<Type> result = (List<Type>) executeCallSingleValueReturn(function, List.class); return convertToNative(result); } }); }
Example #28
Source File: HelloWorld.java From WeBASE-Front with Apache License 2.0 | 5 votes |
public String setSeq(List<BigInteger> _ua) { final Function function = new Function( FUNC_SET, Arrays.<Type>asList(_ua.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"):new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>( org.fisco.bcos.web3j.abi.Utils.typeMap(_ua, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class))), Collections.<TypeReference<?>>emptyList()); return createTransactionSeq(function); }
Example #29
Source File: EvidenceSignersData.java From WeBASE-Front with Apache License 2.0 | 5 votes |
public RemoteCall<List> getSigners() { final Function function = new Function(FUNC_GETSIGNERS, Arrays.<Type>asList(), Arrays.<TypeReference<?>>asList(new TypeReference<DynamicArray<Address>>() {})); return new RemoteCall<List>( new Callable<List>() { @Override @SuppressWarnings("unchecked") public List call() throws Exception { List<Type> result = (List<Type>) executeCallSingleValueReturn(function, List.class); return convertToNative(result); } }); }
Example #30
Source File: Evidence.java From WeBASE-Front with Apache License 2.0 | 5 votes |
public RemoteCall<List> getSigners() { final Function function = new Function(FUNC_GETSIGNERS, Arrays.<Type>asList(), Arrays.<TypeReference<?>>asList(new TypeReference<DynamicArray<Address>>() {})); return new RemoteCall<List>( new Callable<List>() { @Override @SuppressWarnings("unchecked") public List call() throws Exception { List<Type> result = (List<Type>) executeCallSingleValueReturn(function, List.class); return convertToNative(result); } }); }