本文整理汇总了Java中org.web3j.abi.TypeReference类的典型用法代码示例。如果您正苦于以下问题:Java TypeReference类的具体用法?Java TypeReference怎么用?Java TypeReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeReference类属于org.web3j.abi包,在下文中一共展示了TypeReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transferEventObservable
import org.web3j.abi.TypeReference; //导入依赖的package包/类
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 = (Address) eventValues.getIndexedValues().get(0);
typedResponse._to = (Address) eventValues.getIndexedValues().get(1);
typedResponse._value = (Uint256) eventValues.getNonIndexedValues().get(0);
return typedResponse;
}
});
}
示例2: callHash
import org.web3j.abi.TypeReference; //导入依赖的package包/类
private byte[] callHash(String name, Type...parameters) throws InterruptedException, ExecutionException {
Function function = new Function(name,
Arrays.asList(parameters),
Arrays.asList(new TypeReference<Bytes32>() {})
);
String encodedFunction = FunctionEncoder.encode(function);
TransactionManager transactionManager = cfg.getTransactionManager(cfg.getMainAddress());
String channelLibraryAddress = contractsProperties.getAddress().get("ChannelLibrary").toString();
org.web3j.protocol.core.methods.response.EthCall ethCall = web3j.ethCall(
Transaction.createEthCallTransaction(
transactionManager.getFromAddress(), channelLibraryAddress, encodedFunction),
DefaultBlockParameterName.LATEST)
.sendAsync().get();
String value = ethCall.getValue();
List<Type> list = FunctionReturnDecoder.decode(value, function.getOutputParameters());
return ((Bytes32) list.get(0)).getValue();
}
示例3: approvalEventObservable
import org.web3j.abi.TypeReference; //导入依赖的package包/类
public Observable<ApprovalEventResponse> approvalEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
final Event event = new Event("Approval",
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, ApprovalEventResponse>() {
@Override
public ApprovalEventResponse call(Log log) {
EventValues eventValues = extractEventParameters(event, log);
ApprovalEventResponse typedResponse = new ApprovalEventResponse();
typedResponse.owner = (Address) eventValues.getIndexedValues().get(0);
typedResponse.spender = (Address) eventValues.getIndexedValues().get(1);
typedResponse.value = (Uint256) eventValues.getNonIndexedValues().get(0);
return typedResponse;
}
});
}
示例4: payoutEventObservable
import org.web3j.abi.TypeReference; //导入依赖的package包/类
public Observable<PayoutEventResponse> payoutEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
final Event event = new Event("Payout",
Arrays.<TypeReference<?>>asList(),
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, PayoutEventResponse>() {
@Override
public PayoutEventResponse call(Log log) {
EventValues eventValues = extractEventParameters(event, log);
PayoutEventResponse typedResponse = new PayoutEventResponse();
typedResponse.weiPerToken = (Uint256) eventValues.getNonIndexedValues().get(0);
return typedResponse;
}
});
}
示例5: issuanceEventObservable
import org.web3j.abi.TypeReference; //导入依赖的package包/类
public Observable<IssuanceEventResponse> issuanceEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
final Event event = new Event("Issuance",
Arrays.<TypeReference<?>>asList(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, IssuanceEventResponse>() {
@Override
public IssuanceEventResponse call(Log log) {
EventValues eventValues = extractEventParameters(event, log);
IssuanceEventResponse typedResponse = new IssuanceEventResponse();
typedResponse.to = (Address) eventValues.getIndexedValues().get(0);
typedResponse.value = (Uint256) eventValues.getNonIndexedValues().get(0);
return typedResponse;
}
});
}
示例6: newMessageEventObservable
import org.web3j.abi.TypeReference; //导入依赖的package包/类
public Observable<NewMessageEventResponse> newMessageEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
final Event event = new Event("NewMessage",
Arrays.<TypeReference<?>>asList(),
Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}, new TypeReference<Utf8String>() {}));
EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
filter.addSingleTopic(EventEncoder.encode(event));
return web3j.ethLogObservable(filter).map(new Func1<Log, NewMessageEventResponse>() {
@Override
public NewMessageEventResponse call(Log log) {
EventValues eventValues = extractEventParameters(event, log);
NewMessageEventResponse typedResponse = new NewMessageEventResponse();
typedResponse.from = (Address) eventValues.getNonIndexedValues().get(0);
typedResponse.message = (Utf8String) eventValues.getNonIndexedValues().get(1);
return typedResponse;
}
});
}
示例7: transferEventObservable
import org.web3j.abi.TypeReference; //导入依赖的package包/类
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 = (Address) eventValues.getIndexedValues().get(0);
typedResponse.to = (Address) eventValues.getIndexedValues().get(1);
typedResponse.value = (Uint256) eventValues.getNonIndexedValues().get(0);
return typedResponse;
}
});
}
示例8: pendingEventSet
import org.web3j.abi.TypeReference; //导入依赖的package包/类
@OnClick(R.id.pending_event_set)
public void pendingEventSet() {
final Event event = new Event(
"Print",
Collections.emptyList(),
Collections.singletonList(new TypeReference<Uint256>() {
}));
FilterManager.Filter filter = new FilterManager.Filter(event, HELLO_CONTRACT_ADDR);
FilterManager.pendingFilterLogs(filter)
.compose(bindToLifecycle())
.map(log -> Utils.extractEventParameters(event, log))
.subscribe(eventValues -> {
Log.i(TAG, "output : " + eventValues.getNonIndexedValues().get(0).getValue());
}, Throwable::printStackTrace);
}
示例9: getNotifyEvents
import org.web3j.abi.TypeReference; //导入依赖的package包/类
public List<NotifyEventResponse> getNotifyEvents(Receipt transactionReceipt) throws Exception {
final Event event = new Event(
"Notify",
Collections.emptyList(),
Arrays.asList(
new TypeReference<Uint256>() {
},
new TypeReference<Uint256>() {
}
));
List<EventValues> valueList = extractEventParameters(event, transactionReceipt);
ArrayList<NotifyEventResponse> responses = new ArrayList<>(valueList.size());
for (EventValues eventValues : valueList) {
NotifyEventResponse typedResponse = new NotifyEventResponse();
typedResponse.input = (Uint256) eventValues.getNonIndexedValues().get(0);
typedResponse.result = (Uint256) eventValues.getNonIndexedValues().get(1);
responses.add(typedResponse);
}
return responses;
}
示例10: notifyEventObservable
import org.web3j.abi.TypeReference; //导入依赖的package包/类
public Observable<NotifyEventResponse> notifyEventObservable() {
final Event event = new Event(
"Notify",
Collections.emptyList(),
Arrays.asList(
new TypeReference<Uint256>() {
},
new TypeReference<Uint256>() {
}
));
return filterLogs(event)
.map(eventValues -> {
NotifyEventResponse typedResponse = new NotifyEventResponse();
typedResponse.input = (Uint256) eventValues.getNonIndexedValues().get(0);
typedResponse.result = (Uint256) eventValues.getNonIndexedValues().get(1);
return typedResponse;
});
}
示例11: createTokenTransferData
import org.web3j.abi.TypeReference; //导入依赖的package包/类
public static byte[] createTokenTransferData(String to, BigInteger tokenAmount) {
List<Type> params = Arrays.asList(new Address(to), new Uint256(tokenAmount));
List<TypeReference<?>> returnTypes = Arrays.<TypeReference<?>>asList(new TypeReference<Bool>() {
});
Function function = new Function("transfer", params, returnTypes);
String encodedFunction = FunctionEncoder.encode(function);
return Numeric.hexStringToByteArray(Numeric.cleanHexPrefix(encodedFunction));
}
示例12: transferEventObservable
import org.web3j.abi.TypeReference; //导入依赖的package包/类
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;
}
});
}
示例13: getMintedEvents
import org.web3j.abi.TypeReference; //导入依赖的package包/类
public List<MintedEventResponse> getMintedEvents(TransactionReceipt transactionReceipt) {
final Event event = new Event("Minted",
Arrays.<TypeReference<?>>asList(),
Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}, new TypeReference<Uint256>() {}));
List<EventValues> valueList = extractEventParameters(event, transactionReceipt);
ArrayList<MintedEventResponse> responses = new ArrayList<MintedEventResponse>(valueList.size());
for (EventValues eventValues : valueList) {
MintedEventResponse typedResponse = new MintedEventResponse();
typedResponse._addr = (Address) eventValues.getNonIndexedValues().get(0);
typedResponse.tokens = (Uint256) eventValues.getNonIndexedValues().get(1);
responses.add(typedResponse);
}
return responses;
}
示例14: getPayoutEvents
import org.web3j.abi.TypeReference; //导入依赖的package包/类
public List<PayoutEventResponse> getPayoutEvents(TransactionReceipt transactionReceipt) {
final Event event = new Event("Payout",
Arrays.<TypeReference<?>>asList(),
Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
List<EventValues> valueList = extractEventParameters(event, transactionReceipt);
ArrayList<PayoutEventResponse> responses = new ArrayList<PayoutEventResponse>(valueList.size());
for (EventValues eventValues : valueList) {
PayoutEventResponse typedResponse = new PayoutEventResponse();
typedResponse.weiPerToken = (Uint256) eventValues.getNonIndexedValues().get(0);
responses.add(typedResponse);
}
return responses;
}
示例15: getTransferEvents
import org.web3j.abi.TypeReference; //导入依赖的package包/类
public List<TransferEventResponse> getTransferEvents(TransactionReceipt transactionReceipt) {
final Event event = new Event("Transfer",
Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}, new TypeReference<Address>() {}),
Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
List<EventValues> valueList = extractEventParameters(event, transactionReceipt);
ArrayList<TransferEventResponse> responses = new ArrayList<TransferEventResponse>(valueList.size());
for (EventValues eventValues : valueList) {
TransferEventResponse typedResponse = new TransferEventResponse();
typedResponse._from = (Address) eventValues.getIndexedValues().get(0);
typedResponse._to = (Address) eventValues.getIndexedValues().get(1);
typedResponse._value = (Uint256) eventValues.getNonIndexedValues().get(0);
responses.add(typedResponse);
}
return responses;
}