本文整理了Java中org.web3j.utils.Numeric.encodeQuantity()
方法的一些代码示例,展示了Numeric.encodeQuantity()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Numeric.encodeQuantity()
方法的具体详情如下:
包路径:org.web3j.utils.Numeric
类名称:Numeric
方法名:encodeQuantity
暂无
代码示例来源:origin: web3j/web3j
private String convert(BigInteger value) {
if (value != null) {
return Numeric.encodeQuantity(value);
} else {
return null;
}
}
}
代码示例来源:origin: web3j/web3j
private static String convert(BigInteger value) {
if (value != null) {
return Numeric.encodeQuantity(value);
} else {
return null; // we don't want the field to be encoded if not present
}
}
}
代码示例来源:origin: web3j/web3j
@Override
@JsonValue
public String getValue() {
return Numeric.encodeQuantity(blockNumber);
}
代码示例来源:origin: web3j/web3j
@Override
public Request<?, EthBlock> ethGetUncleByBlockHashAndIndex(
String blockHash, BigInteger transactionIndex) {
return new Request<>(
"eth_getUncleByBlockHashAndIndex",
Arrays.asList(
blockHash,
Numeric.encodeQuantity(transactionIndex)),
web3jService,
EthBlock.class);
}
代码示例来源:origin: web3j/web3j
@Override
public Request<?, EthTransaction> ethGetTransactionByBlockHashAndIndex(
String blockHash, BigInteger transactionIndex) {
return new Request<>(
"eth_getTransactionByBlockHashAndIndex",
Arrays.asList(
blockHash,
Numeric.encodeQuantity(transactionIndex)),
web3jService,
EthTransaction.class);
}
代码示例来源:origin: web3j/web3j
@Override
public Request<?, EthGetStorageAt> ethGetStorageAt(
String address, BigInteger position, DefaultBlockParameter defaultBlockParameter) {
return new Request<>(
"eth_getStorageAt",
Arrays.asList(
address,
Numeric.encodeQuantity(position),
defaultBlockParameter.getValue()),
web3jService,
EthGetStorageAt.class);
}
代码示例来源:origin: web3j/web3j
@Override
public Request<?, EthBlock> ethGetUncleByBlockNumberAndIndex(
DefaultBlockParameter defaultBlockParameter, BigInteger uncleIndex) {
return new Request<>(
"eth_getUncleByBlockNumberAndIndex",
Arrays.asList(
defaultBlockParameter.getValue(),
Numeric.encodeQuantity(uncleIndex)),
web3jService,
EthBlock.class);
}
代码示例来源:origin: web3j/web3j
@Override
public Request<?, EthTransaction> ethGetTransactionByBlockNumberAndIndex(
DefaultBlockParameter defaultBlockParameter, BigInteger transactionIndex) {
return new Request<>(
"eth_getTransactionByBlockNumberAndIndex",
Arrays.asList(
defaultBlockParameter.getValue(),
Numeric.encodeQuantity(transactionIndex)),
web3jService,
EthTransaction.class);
}
代码示例来源:origin: web3j/web3j
@Test
public void testQuantityEncode() {
assertThat(Numeric.encodeQuantity(BigInteger.valueOf(0)), is("0x0"));
assertThat(Numeric.encodeQuantity(BigInteger.valueOf(1)), is("0x1"));
assertThat(Numeric.encodeQuantity(BigInteger.valueOf(1024)), is("0x400"));
assertThat(Numeric.encodeQuantity(
BigInteger.valueOf(Long.MAX_VALUE)), is("0x7fffffffffffffff"));
assertThat(Numeric.encodeQuantity(
new BigInteger("204516877000845695339750056077105398031")),
is("0x99dc848b94efc27edfad28def049810f"));
}
代码示例来源:origin: web3j/web3j
@Test(expected = MessageEncodingException.class)
public void testQuantityEncodeNegative() {
Numeric.encodeQuantity(BigInteger.valueOf(-1));
}
代码示例来源:origin: web3j/web3j
private EthBlock createBlockWithTransactions(int blockNumber, List<Transaction> transactions) {
EthBlock ethBlock = new EthBlock();
EthBlock.Block block = new EthBlock.Block();
block.setNumber(Numeric.encodeQuantity(BigInteger.valueOf(blockNumber)));
List<EthBlock.TransactionResult> transactionResults =
transactions.stream()
.map(it -> (EthBlock.TransactionResult<Transaction>) () -> it)
.collect(Collectors.toList());
block.setTransactions(transactionResults);
ethBlock.setResult(block);
return ethBlock;
}
代码示例来源:origin: web3j/web3j
private void configureLatestBlock(long timestamp) throws IOException {
EthBlock.Block block = new EthBlock.Block();
block.setTimestamp(Numeric.encodeQuantity(BigInteger.valueOf(timestamp)));
EthBlock ethBlock = new EthBlock();
ethBlock.setResult(block);
when(web3jService.send(any(Request.class), eq(EthBlock.class)))
.thenReturn(ethBlock);
}
代码示例来源:origin: web3j/web3j
private EthBlock createBlock(int number) {
EthBlock ethBlock = new EthBlock();
EthBlock.Block block = new EthBlock.Block();
block.setNumber(Numeric.encodeQuantity(BigInteger.valueOf(number)));
ethBlock.setResult(block);
return ethBlock;
}
代码示例来源:origin: web3j/web3j-spring-boot-starter
Mockito.when(web3j.ethBlockNumber().sendAsync()).thenReturn(supplyAsync(() -> {
EthBlockNumber ethBlockNumber = new EthBlockNumber();
ethBlockNumber.setResult(Numeric.encodeQuantity(blockNumber));
return ethBlockNumber;
}));
Mockito.when(web3j.netPeerCount().sendAsync()).thenReturn(supplyAsync(() -> {
NetPeerCount netPeerCount = new NetPeerCount();
netPeerCount.setResult(Numeric.encodeQuantity(netPeer));
return netPeerCount;
}));
内容来源于网络,如有侵权,请联系作者删除!