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 } } }
private BigInteger convert(String value) { if (value != null) { return Numeric.decodeQuantity(value); } else { return null; } }
public Transaction(String from, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String data) { this.from = from; this.to = to; this.gas = gasLimit; this.gasPrice = gasPrice; this.value = value; if (data != null) { this.data = Numeric.prependHexPrefix(data); } this.nonce = nonce; }
public static String toHexStringWithPrefixSafe(BigInteger value) { String result = toHexStringNoPrefix(value); if (result.length() < 2) { result = Strings.zeros(1) + result; } return HEX_PREFIX + result; }
public static BigInteger toBigInt(String hexValue) { String cleanValue = cleanHexPrefix(hexValue); return toBigIntNoPrefix(cleanValue); }
protected RawTransaction(BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String data) { this.nonce = nonce; this.gasPrice = gasPrice; this.gasLimit = gasLimit; this.to = to; this.value = value; if (data != null) { this.data = Numeric.cleanHexPrefix(data); } }
private String getWeb3jVersion() { String version; try { // This only works if run as part of the web3j command line tools which contains // a version.properties file version = Version.getVersion(); } catch (IOException | NullPointerException e) { version = Version.DEFAULT; } return "\n<p>Generated with web3j version " + version + ".\n"; }
public static String prependHexPrefix(String input) { if (!containsHexPrefix(input)) { return HEX_PREFIX + input; } else { return input; } }
public static String toCsv(List<String> src) { // return src == null ? null : String.join(", ", src.toArray(new String[0])); return join(src, ", "); }
/** * Perform request asynchronously with a future. * * @return a future containing our function */ public CompletableFuture<T> sendAsync() { return Async.run(this::send); }
public static Flowable<BigInteger> range( final BigInteger startValue, final BigInteger endValue) { return range(startValue, endValue, true); }
public static byte[] trimLeadingZeroes(byte[] bytes) { return trimLeadingBytes(bytes, (byte) 0); } }
public BigInteger getNumber() { return Numeric.decodeQuantity(number); }
private String convert(BigInteger value) { if (value != null) { return Numeric.encodeQuantity(value); } else { return null; } } }
public BigInteger getNonce() { return Numeric.decodeQuantity(nonce); }
public BigInteger getDifficulty() { return Numeric.decodeQuantity(difficulty); }
public BigInteger getSize() { return Numeric.decodeQuantity(size); }
public BigInteger getTimestamp() { return Numeric.decodeQuantity(timestamp); }
public BigInteger getValue() { return Numeric.decodeQuantity(value); }
public BigInteger getGas() { return Numeric.decodeQuantity(gas); }