use of org.fisco.bcos.web3j.abi.datatypes.Type in project web3sdk by FISCO-BCOS.
the class TypeDecoder method decodeDynamicArray.
@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);
}
use of org.fisco.bcos.web3j.abi.datatypes.Type in project web3sdk by FISCO-BCOS.
the class Utils method getOffset.
public static <T extends Type> int getOffset(java.lang.reflect.Type type) throws ClassNotFoundException {
if (Utils.dynamicType(type)) {
return 1;
}
Class<T> cls = Utils.getClassType(type);
if (StaticArray.class.isAssignableFrom(cls)) {
int length = Integer.parseInt(cls.getSimpleName().substring(StaticArray.class.getSimpleName().length()));
java.lang.reflect.Type[] types = ((ParameterizedType) type).getActualTypeArguments();
return getOffset(types[0]) * length;
} else {
return 1;
}
}
use of org.fisco.bcos.web3j.abi.datatypes.Type in project web3sdk by FISCO-BCOS.
the class ChainGovernance method getUpdateCommitteeMemberWeightOutput.
public Tuple1<BigInteger> getUpdateCommitteeMemberWeightOutput(TransactionReceipt transactionReceipt) {
String data = transactionReceipt.getOutput();
final Function function = new Function(FUNC_UPDATECOMMITTEEMEMBERWEIGHT, 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());
}
use of org.fisco.bcos.web3j.abi.datatypes.Type in project web3sdk by FISCO-BCOS.
the class ChainGovernance method getRevokeOperatorInput.
public Tuple1<String> getRevokeOperatorInput(TransactionReceipt transactionReceipt) {
String data = transactionReceipt.getInput().substring(10);
final Function function = new Function(FUNC_REVOKEOPERATOR, 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());
}
use of org.fisco.bcos.web3j.abi.datatypes.Type in project web3sdk by FISCO-BCOS.
the class ChainGovernance method getGrantCommitteeMemberOutput.
public Tuple1<BigInteger> getGrantCommitteeMemberOutput(TransactionReceipt transactionReceipt) {
String data = transactionReceipt.getOutput();
final Function function = new Function(FUNC_GRANTCOMMITTEEMEMBER, 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());
}
Aggregations