diff --git a/web3j-ext/web3j-ext/build.gradle b/web3j-ext/web3j-ext/build.gradle index 60253d55b..e77f6f978 100644 --- a/web3j-ext/web3j-ext/build.gradle +++ b/web3j-ext/web3j-ext/build.gradle @@ -76,7 +76,7 @@ publishing { } } repositories { - maven { + maven { def releasesRepoUrl = layout.buildDirectory.dir('libs') url = releasesRepoUrl } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/KaiaCredentials.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/KaiaCredentials.java index 1a5ee7ba8..c1e984200 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/KaiaCredentials.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/KaiaCredentials.java @@ -29,7 +29,9 @@ public class KaiaCredentials { private KaiaCredentials(ECKeyPair ecKeyPair, String address) { this.ecKeyPair = ecKeyPair; - this.address = !Strings.isEmpty(address) ? Numeric.toHexStringWithPrefixZeroPadded(Numeric.toBigInt(address), 40) : ""; + this.address = !Strings.isEmpty(address) + ? Numeric.toHexStringWithPrefixZeroPadded(Numeric.toBigInt(address), 40) + : ""; } public ECKeyPair getEcKeyPair() { @@ -69,7 +71,7 @@ public static KaiaCredentials create(ECKeyPair ecKeyPair) { * Static method for creating KaiaCredentials instance * * @param privateKey private key for transaction signing - * @param address address of account + * @param address address of account * @return KaiaCredentials */ public static KaiaCredentials create(String privateKey, String address) { @@ -78,27 +80,24 @@ public static KaiaCredentials create(String privateKey, String address) { public Credentials convertToCredentials() { Credentials Ethcredentials = Credentials.create(this.getEcKeyPair()); - return Ethcredentials; - + return Ethcredentials; } - + public boolean isDeCoupled() { String address = Numeric.prependHexPrefix(Keys.getAddress(ecKeyPair)); return !(address.equals(this.address)); } - public static boolean isDeCoupled(String privKey, String address) { ECKeyPair ecKeyPair = ECKeyPair.create(Numeric.toBigInt(privKey)); return !(address.equals(Numeric.prependHexPrefix(Keys.getAddress(ecKeyPair)))); } - /** * Static method for creating KaiaCredentials instance * * @param ecKeyPair ecKeyPair for transaction signing - * @param address address of account + * @param address address of account * @return KaiaCredentials */ public static KaiaCredentials create(ECKeyPair ecKeyPair, String address) { diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/KaiaRawTransaction.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/KaiaRawTransaction.java index 0f889835b..517a0a36a 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/KaiaRawTransaction.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/KaiaRawTransaction.java @@ -58,7 +58,7 @@ * paper. */ public class KaiaRawTransaction extends RawTransaction { - private byte[] value; + private byte[] value; private Set signatureData; public KaiaRawTransaction(ITransaction transaction, Set signatureData) { diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKey.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKey.java index f2850c1b0..1686424ea 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKey.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKey.java @@ -25,12 +25,12 @@ public interface AccountKey { byte[] toRlp(); enum Type { - NIL((byte)0x0, AccountKeyNil.class), - LEGACY((byte)0x01, AccountKeyLegacy.class), - PUBLIC((byte)0x02, AccountKeyPublic.class), - FAIL((byte)0x03, AccountKeyFail.class), - MULTISIG((byte)0x04, AccountKeyWeightedMultiSig.class), - ROLEBASED((byte)0x05, AccountKeyRoleBased.class); + NIL((byte) 0x0, AccountKeyNil.class), + LEGACY((byte) 0x01, AccountKeyLegacy.class), + PUBLIC((byte) 0x02, AccountKeyPublic.class), + FAIL((byte) 0x03, AccountKeyFail.class), + MULTISIG((byte) 0x04, AccountKeyWeightedMultiSig.class), + ROLEBASED((byte) 0x05, AccountKeyRoleBased.class); private byte value; private Class keyClass; @@ -48,9 +48,9 @@ public Class getKeyClass() { return keyClass; } - public static AccountKey.Type findByValue(byte value){ - for(AccountKey.Type v : values()){ - if( v.getValue() == value ){ + public static AccountKey.Type findByValue(byte value) { + for (AccountKey.Type v : values()) { + if (v.getValue() == value) { return v; } } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyDecoder.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyDecoder.java index c8aba10e3..da7b0a233 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyDecoder.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyDecoder.java @@ -22,7 +22,7 @@ import java.util.function.Function; public class AccountKeyDecoder { - private static HashMap> typeMap = new HashMap>(){ + private static HashMap> typeMap = new HashMap>() { { put(AccountKey.Type.PUBLIC, AccountKeyPublic::decodeFromRlp); put(AccountKey.Type.MULTISIG, AccountKeyWeightedMultiSig::decodeFromRlp); @@ -33,7 +33,7 @@ public class AccountKeyDecoder { }; public static AccountKey fromRlp(String raw) { - if(Numeric.toHexString(AccountKeyNil.RLP).equals(raw)) + if (Numeric.toHexString(AccountKeyNil.RLP).equals(raw)) return AccountKeyNil.create(); AccountKey.Type type = AccountKey.Type.findByValue(Numeric.hexStringToByteArray(raw)[0]); diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyFail.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyFail.java index 91c1b2ac4..d05a87c51 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyFail.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyFail.java @@ -21,13 +21,15 @@ import java.util.Arrays; /** - * AccountKeyFail is used for smart contract accounts so that a transaction sent from + * AccountKeyFail is used for smart contract accounts so that a transaction sent + * from * the smart contract account always fails. - * If an account has the key AccountKeyFail, the tx validation process always fails. + * If an account has the key AccountKeyFail, the tx validation process always + * fails. */ public class AccountKeyFail implements AccountKey { - private static byte[] RLP = new byte[]{(byte) 0x03, (byte) 0xc0}; + private static byte[] RLP = new byte[] { (byte) 0x03, (byte) 0xc0 }; protected AccountKeyFail() { } @@ -56,8 +58,10 @@ public byte[] toRlp() { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; AccountKeyFail that = (AccountKeyFail) o; return Arrays.equals(toRlp(), that.toRlp()); } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyLegacy.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyLegacy.java index c6ac54fd7..9012b8310 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyLegacy.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyLegacy.java @@ -21,22 +21,22 @@ import java.util.Arrays; /** - * AccountKeyLegacy represents a key of legacy account types. If an account has AccountKeyLegacy, + * AccountKeyLegacy represents a key of legacy account types. If an account has + * AccountKeyLegacy, * the tx validation process is done like below (as Ethereum did): *
    - *
  • Get the public key from ecrecover(txhash, txsig)
  • - *
  • Get the address of the public key
  • - *
  • The address is the sender
  • + *
  • Get the public key from ecrecover(txhash, txsig)
  • + *
  • Get the address of the public key
  • + *
  • The address is the sender
  • *
*/ public class AccountKeyLegacy implements AccountKey { - private static byte[] RLP = new byte[]{(byte) 0x01, (byte) 0xc0}; + private static byte[] RLP = new byte[] { (byte) 0x01, (byte) 0xc0 }; protected AccountKeyLegacy() { } - public static AccountKeyLegacy create() { return new AccountKeyLegacy(); } @@ -61,8 +61,10 @@ public byte[] toRlp() { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; AccountKeyLegacy that = (AccountKeyLegacy) o; return Arrays.equals(toRlp(), that.toRlp()); } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyNil.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyNil.java index dbab3f5b1..aebb5fcf7 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyNil.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyNil.java @@ -21,16 +21,21 @@ import java.util.Arrays; /** - * AccountKeyNil represents an empty key. If an account tries to having an AccountKeyNil object, - * the transaction will be failed. AccountKeyNil is only used only for TxTypeAccountUpdate transactions - * with role-based keys. For example, if an account tries to update RoleAccountUpdate key only, the key - * field of the TxTypeAccountUpdate transaction would be: [AccountKeyNil, NewKey, AccountKeyNil] - * Then, only the RoleAccountUpdate key is updated. Other roles are not updated. Refer to the + * AccountKeyNil represents an empty key. If an account tries to having an + * AccountKeyNil object, + * the transaction will be failed. AccountKeyNil is only used only for + * TxTypeAccountUpdate transactions + * with role-based keys. For example, if an account tries to update + * RoleAccountUpdate key only, the key + * field of the TxTypeAccountUpdate transaction would be: [AccountKeyNil, + * NewKey, AccountKeyNil] + * Then, only the RoleAccountUpdate key is updated. Other roles are not updated. + * Refer to the * {@link AccountKeyRoleBased} for more detail. */ public class AccountKeyNil implements AccountKey { - public static byte[] RLP = new byte[]{(byte) 0x80}; + public static byte[] RLP = new byte[] { (byte) 0x80 }; protected AccountKeyNil() { } @@ -59,8 +64,10 @@ public byte[] toRlp() { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; AccountKeyNil that = (AccountKeyNil) o; return Arrays.equals(toRlp(), that.toRlp()); } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyPublic.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyPublic.java index 0ef92e5f8..6f3325b3a 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyPublic.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyPublic.java @@ -29,11 +29,12 @@ /** * AccountKeyPublic is used for accounts having one public key. - * If an account has an AccountKeyPublic object, the tx validation process is done like below: + * If an account has an AccountKeyPublic object, the tx validation process is + * done like below: *
    - *
  • Get the public key derived from ecrecover(txhash, txsig)
  • - *
  • Check that the derived public key is the same as the corresponding
  • - *
  • account's public key
  • + *
  • Get the public key derived from ecrecover(txhash, txsig)
  • + *
  • Check that the derived public key is the same as the corresponding
  • + *
  • account's public key
  • *
*/ public class AccountKeyPublic implements AccountKey { @@ -58,15 +59,14 @@ public static AccountKeyPublic create(BigInteger publicKey) { public static AccountKeyPublic create(String publicKeyX, String publicKeyY) { return new AccountKeyPublic( - Numeric.prependHexPrefix(publicKeyX), Numeric.prependHexPrefix(publicKeyY) - ); + Numeric.prependHexPrefix(publicKeyX), Numeric.prependHexPrefix(publicKeyY)); } @Override public byte[] toRlp() { byte[] encodedTransaction = RlpEncoder.encode( RlpString.create(Numeric.hexStringToByteArray(toCompressedPublicKey()))); - byte[] type = {getType().getValue()}; + byte[] type = { getType().getValue() }; return BytesUtils.concat(type, encodedTransaction); } @@ -111,8 +111,10 @@ public String toString() { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; AccountKeyPublic that = (AccountKeyPublic) o; return Arrays.equals(toRlp(), that.toRlp()); } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyRoleBased.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyRoleBased.java index cad719e34..97c4fe11c 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyRoleBased.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyRoleBased.java @@ -30,16 +30,23 @@ public class AccountKeyRoleBased implements AccountKey { /** - *

First Key : roleTransaction
- * Default key. Transactions other than TxTypeAccountUpdate should be signed by the key of this role. + *

+ * First Key : roleTransaction
+ * Default key. Transactions other than TxTypeAccountUpdate should be signed by + * the key of this role. * - *

Second Key : roleUpdate
- * TxTypeAccountUpdate transaction should be signed by this key. If this key is not present in the account, + *

+ * Second Key : roleUpdate
+ * TxTypeAccountUpdate transaction should be signed by this key. If this key is + * not present in the account, * TxTypeAccountUpdate transaction is validated using RoleTransaction key. * - *

Third Key : roleFeePayer
- * If this account wants to send tx fee instead of the sender, the transaction should be signed by this key. - * If this key is not present in the account, a fee-delegated transaction is validated using RoleTransaction key. + *

+ * Third Key : roleFeePayer
+ * If this account wants to send tx fee instead of the sender, the transaction + * should be signed by this key. + * If this key is not present in the account, a fee-delegated transaction is + * validated using RoleTransaction key. */ private List accountKeys; @@ -91,7 +98,7 @@ public byte[] toRlp() { } byte[] encodedTransaction = RlpEncoder.encode(new RlpList(rlpTypeList)); - byte[] type = {getType().getValue()}; + byte[] type = { getType().getValue() }; return BytesUtils.concat(type, encodedTransaction); } @@ -102,8 +109,10 @@ public Type getType() { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; AccountKeyRoleBased that = (AccountKeyRoleBased) o; return Arrays.equals(toRlp(), that.toRlp()); } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyWeightedMultiSig.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyWeightedMultiSig.java index 3f2b59ce7..2c85dc63b 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyWeightedMultiSig.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/account/AccountKeyWeightedMultiSig.java @@ -28,20 +28,25 @@ import java.util.List; /** - * AccountKeyWeightedMultiSig is an account key type containing a threshold and WeightedPublicKeys. - * WeightedPublicKeys contains a slice of {weight and key}. To be a valid tx for an account associated - * with AccountKeyWeightedMultiSig, the weighted sum of signed public keys should be larger than the threshold. + * AccountKeyWeightedMultiSig is an account key type containing a threshold and + * WeightedPublicKeys. + * WeightedPublicKeys contains a slice of {weight and key}. To be a valid tx for + * an account associated + * with AccountKeyWeightedMultiSig, the weighted sum of signed public keys + * should be larger than the threshold. */ public class AccountKeyWeightedMultiSig implements AccountKey { /** - * Validation threshold. To be a valid transaction, the weight sum of signatures should be larger than + * Validation threshold. To be a valid transaction, the weight sum of signatures + * should be larger than * or equal to the threshold. */ private BigInteger threshold; /** - * A slice of weighted public keys. A weighted public key contains a weight and a public key. + * A slice of weighted public keys. A weighted public key contains a weight and + * a public key. */ private List weightedPublicKeys = new ArrayList<>(); @@ -84,7 +89,7 @@ public byte[] toRlp() { rlpTypeList.add(new RlpList(rlpWeightedPublicKeys)); byte[] encodedTransaction = RlpEncoder.encode(new RlpList(rlpTypeList)); - byte[] type = {getType().getValue()}; + byte[] type = { getType().getValue() }; return BytesUtils.concat(type, encodedTransaction); } @@ -102,7 +107,8 @@ public static AccountKeyWeightedMultiSig decodeFromRlp(byte[] rawTransaction) { RlpList rlpWeightedPublicKey = (RlpList) item; BigInteger weight = ((RlpString) rlpWeightedPublicKey.getValues().get(0)).asPositiveBigInteger(); String compressedPublicKey = ((RlpString) rlpWeightedPublicKey.getValues().get(1)).asString(); - weightedPublicKeys.add(new WeightedPublicKey(weight, AccountKeyPublicUtils.decompressKey(compressedPublicKey))); + weightedPublicKeys + .add(new WeightedPublicKey(weight, AccountKeyPublicUtils.decompressKey(compressedPublicKey))); } return new AccountKeyWeightedMultiSig(threshold, weightedPublicKeys); @@ -144,8 +150,10 @@ public AccountKeyPublic getKey() { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; AccountKeyWeightedMultiSig that = (AccountKeyWeightedMultiSig) o; return Arrays.equals(toRlp(), that.toRlp()); } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/fee/FeePayer.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/fee/FeePayer.java index ead499316..d76136fb3 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/fee/FeePayer.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/fee/FeePayer.java @@ -1,4 +1,5 @@ package org.web3j.crypto.transaction.fee; + import org.web3j.crypto.KaiaCredentials; import org.web3j.crypto.KaiaRawTransaction; import org.web3j.crypto.KaiaSignatureData; @@ -16,6 +17,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; + public class FeePayer { final static String EMPTY_FEE_PAYER_ADDRESS = "0x"; @@ -55,7 +57,7 @@ public KaiaRawTransaction sign(TxTypeFeeDelegate txType) { rlpTypeList.add(new RlpList(feePayerSignatureList)); byte[] encodedTransaction = RlpEncoder.encode(new RlpList(rlpTypeList)); - byte[] type = {txType.getKaiaType().get()}; + byte[] type = { txType.getKaiaType().get() }; byte[] rawTx = BytesUtils.concat(type, encodedTransaction); return new KaiaRawTransaction(null, rawTx, feePayerSignatureDataSet); } @@ -92,8 +94,8 @@ private Set getFeePayerSignatureData(AbstractTxType txType) { rlpTypeList.addAll(signatureData.toRlpList().getValues()); byte[] encodedTransaction = RlpEncoder.encode(new RlpList(rlpTypeList)); - Sign.SignatureData signedSignatureData = Sign.signMessage(encodedTransaction, credentials.getEcKeyPair()); - feePayerSignatureDataSet.add(KaiaSignatureData.createEip155KaiaSignatureData(signedSignatureData, chainId)); + Sign.SignatureData signedSignatureData = Sign.signMessage(encodedTransaction, credentials.getEcKeyPair()); + feePayerSignatureDataSet.add(KaiaSignatureData.createEip155KaiaSignatureData(signedSignatureData, chainId)); return feePayerSignatureDataSet; } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/AbstractTxType.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/AbstractTxType.java index 1fa2dfc47..f3f70f439 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/AbstractTxType.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/AbstractTxType.java @@ -86,7 +86,7 @@ public AbstractTxType(TxType.Type type, BigInteger nonce, BigInteger gasPrice, B } public AbstractTxType(long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, - String from, String to, BigInteger value) { + String from, String to, BigInteger value) { this.chainId = chainId; this.type = type; this.nonce = nonce; diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/KaiaTransactionType.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/KaiaTransactionType.java index ed2e7cf45..05b06cdbb 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/KaiaTransactionType.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/KaiaTransactionType.java @@ -40,4 +40,3 @@ public boolean isEip2930() { return this.equals(KaiaTransactionType.EIP2930); } } - diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeAccountUpdate.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeAccountUpdate.java index 07030a022..8f41183f0 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeAccountUpdate.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeAccountUpdate.java @@ -14,39 +14,42 @@ import org.web3j.utils.Numeric; public class TxTypeAccountUpdate extends AbstractTxType { - + /** * newly created accountKey */ private final AccountKey accountKey; - public TxTypeAccountUpdate(TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, AccountKey accountKey) { + public TxTypeAccountUpdate(TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, + String from, AccountKey accountKey) { super(type, nonce, gasPrice, gasLimit, from, "", BigInteger.ZERO); this.accountKey = accountKey; } - public static TxTypeAccountUpdate createTransaction(TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, AccountKey accountKey) { + public static TxTypeAccountUpdate createTransaction(TxType.Type type, BigInteger nonce, BigInteger gasPrice, + BigInteger gasLimit, String from, AccountKey accountKey) { return new TxTypeAccountUpdate(type, nonce, gasPrice, gasLimit, from, accountKey); } - public TxTypeAccountUpdate(long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, AccountKey accountKey) { + public TxTypeAccountUpdate(long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, + BigInteger gasLimit, String from, AccountKey accountKey) { super(chainId, type, nonce, gasPrice, gasLimit, from, "", BigInteger.ZERO); this.accountKey = accountKey; - + } - public static TxTypeAccountUpdate createTransaction(long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, AccountKey accountKey) { + public static TxTypeAccountUpdate createTransaction(long chainId, TxType.Type type, BigInteger nonce, + BigInteger gasPrice, BigInteger gasLimit, String from, AccountKey accountKey) { return new TxTypeAccountUpdate(chainId, type, nonce, gasPrice, gasLimit, from, accountKey); } - - public AccountKey getAccountKey() { return accountKey; } /** - * create RlpTyp List which contains nonce, gas price, gas limit, from and accountKey + * create RlpTyp List which contains nonce, gas price, gas limit, from and + * accountKey * List elements can be different depending on transaction type. * * @return List RlpType List @@ -71,13 +74,15 @@ public Type getKaiaType() { } /** - * decode transaction hash from sender to reconstruct transaction with fee payer signature. + * decode transaction hash from sender to reconstruct transaction with fee payer + * signature. * * @param rawTransaction RLP-encoded signed transaction from sender * @return TxTypeAccountUpdate decoded transaction */ public static TxTypeAccountUpdate decodeFromRawTransaction(byte[] rawTransaction) { - //TxHashRLP = type + encode([nonce, gasPrice, gas, from, rlpEncodedKey, txSignatures]) + // TxHashRLP = type + encode([nonce, gasPrice, gas, from, rlpEncodedKey, + // txSignatures]) try { byte[] rawTransactionExceptType = KaiaTransactionUtils.getRawTransactionNoType(rawTransaction); RlpList rlpList = RlpDecoder.decode(rawTransactionExceptType); @@ -90,8 +95,8 @@ public static TxTypeAccountUpdate decodeFromRawTransaction(byte[] rawTransaction String rawAccountKey = ((RlpString) values.get(4)).asString(); TxType.Type type = Type.ACCOUNT_UPDATE; - TxTypeAccountUpdate tx - = TxTypeAccountUpdate.createTransaction(type, nonce, gasPrice, gasLimit, from, AccountKeyDecoder.fromRlp(rawAccountKey)); + TxTypeAccountUpdate tx = TxTypeAccountUpdate.createTransaction(type, nonce, gasPrice, gasLimit, from, + AccountKeyDecoder.fromRlp(rawAccountKey)); tx.addSignatureData(values, 5); return tx; @@ -125,5 +130,4 @@ public TransactionType getType() { // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'getType'"); } -} - +} diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeCancel.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeCancel.java index c4e2bc2d6..c26e5733f 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeCancel.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeCancel.java @@ -10,25 +10,27 @@ import org.web3j.utils.KaiaTransactionUtils; import org.web3j.utils.Numeric; -public class TxTypeCancel extends AbstractTxType { +public class TxTypeCancel extends AbstractTxType { protected TxTypeCancel( TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from) { super(type, nonce, gasPrice, gasLimit, from, "", BigInteger.ZERO); } public static TxTypeCancel createTransaction( - TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from) { + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from) { return new TxTypeCancel(type, nonce, gasPrice, gasLimit, from); } + protected TxTypeCancel( long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from) { super(chainId, type, nonce, gasPrice, gasLimit, from, "", BigInteger.ZERO); } public static TxTypeCancel createTransaction( - long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from) { + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from) { return new TxTypeCancel(type, nonce, gasPrice, gasLimit, from); } + /** * create RlpType List which contains nonce, gas price, gas limit and from. * List elements can be different depending on transaction type. @@ -54,8 +56,10 @@ public TxType.Type getKaiaType() { } /** - * decode transaction hash from sender to reconstruct transaction with fee payer signature. - // * + * decode transaction hash from sender to reconstruct transaction with fee payer + * signature. + * // * + * * @param rawTransaction RLP-encoded signed transaction from sender * @return TxTypeCancel decoded transaction */ @@ -72,8 +76,7 @@ public static TxTypeCancel decodeFromRawTransaction(byte[] rawTransaction) { String from = ((RlpString) values.get(3)).asString(); TxType.Type type = Type.CANCEL; - TxTypeCancel tx - = TxTypeCancel.createTransaction(type, nonce, gasPrice, gasLimit, from); + TxTypeCancel tx = TxTypeCancel.createTransaction(type, nonce, gasPrice, gasLimit, from); tx.addSignatureData(values, 4); return tx; } catch (Exception e) { diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeChainDataAnchoring.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeChainDataAnchoring.java index 996902094..49dcd964c 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeChainDataAnchoring.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeChainDataAnchoring.java @@ -13,11 +13,11 @@ /** * Transaction class used for signing 1559 transactions locally.
- * For the specification, refer to p4 of the yellow + * For the specification, refer to p4 of the + * yellow * paper. */ -public class TxTypeChainDataAnchoring extends AbstractTxType { - +public class TxTypeChainDataAnchoring extends AbstractTxType { /** * data of the child chain @@ -25,24 +25,28 @@ public class TxTypeChainDataAnchoring extends AbstractTxType { private final byte[] anchoredData; protected TxTypeChainDataAnchoring( - TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, byte[] anchoredData) { + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, + byte[] anchoredData) { super(type, nonce, gasPrice, gasLimit, from, "", BigInteger.ZERO); this.anchoredData = anchoredData; } public static TxTypeChainDataAnchoring createTransaction( - TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, byte[] anchoredData) { + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, + byte[] anchoredData) { return new TxTypeChainDataAnchoring(type, nonce, gasPrice, gasLimit, from, anchoredData); } protected TxTypeChainDataAnchoring( - long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, byte[] anchoredData) { + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, + byte[] anchoredData) { super(chainId, type, nonce, gasPrice, gasLimit, from, "", BigInteger.ZERO); this.anchoredData = anchoredData; } public static TxTypeChainDataAnchoring createTransaction( - long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, byte[] anchoredData) { + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, + byte[] anchoredData) { return new TxTypeChainDataAnchoring(chainId, type, nonce, gasPrice, gasLimit, from, anchoredData); } @@ -51,7 +55,8 @@ public byte[] getAnchoredData() { } /** - * create RlpType List which contains nonce, gas price, gas limit, to, value, from and anchoredData. + * create RlpType List which contains nonce, gas price, gas limit, to, value, + * from and anchoredData. * List elements can be different depending on transaction type. * * @return List RlpType List @@ -76,7 +81,8 @@ public Type getKaiaType() { } /** - * decode transaction hash from sender to reconstruct transaction with fee payer signature. + * decode transaction hash from sender to reconstruct transaction with fee payer + * signature. * * @param rawTransaction RLP-encoded signed transaction from sender * @return TxTypeChainDataAnchoringTransaction decoded transaction @@ -91,14 +97,12 @@ public static TxTypeChainDataAnchoring decodeFromRawTransaction(byte[] rawTransa BigInteger gasLimit = ((RlpString) values.get(2)).asPositiveBigInteger(); String from = ((RlpString) values.get(3)).asString(); byte[] payload = ((RlpString) values.get(4)).getBytes(); - TxType.Type type= Type.CHAIN_DATA_ANCHORING; + TxType.Type type = Type.CHAIN_DATA_ANCHORING; - TxTypeChainDataAnchoring tx - = new TxTypeChainDataAnchoring(type, nonce, gasPrice, gasLimit, from, payload); + TxTypeChainDataAnchoring tx = new TxTypeChainDataAnchoring(type, nonce, gasPrice, gasLimit, from, payload); tx.addSignatureData(values, 5); return tx; } - /** * @param rawTransaction RLP-encoded signed transaction from sender @@ -108,22 +112,22 @@ public static TxTypeChainDataAnchoring decodeFromRawTransaction(String rawTransa return decodeFromRawTransaction(Numeric.hexStringToByteArray(Numeric.cleanHexPrefix(rawTransaction))); } - @Override - public List asRlpValues(SignatureData signatureData) { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getData() { - // TODO Auto-generated method stub - return null; - } - - @Override - public TransactionType getType() { - // TODO Auto-generated method stub - return null; - } + @Override + public List asRlpValues(SignatureData signatureData) { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getData() { + // TODO Auto-generated method stub + return null; + } + + @Override + public TransactionType getType() { + // TODO Auto-generated method stub + return null; + } } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegate.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegate.java index daf7bc64d..1f7043b91 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegate.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegate.java @@ -31,10 +31,10 @@ public TxTypeFeeDelegate(TxType.Type type, BigInteger nonce, BigInteger gasPrice } public TxTypeFeeDelegate(long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, - String from, String to, BigInteger value) { - super(chainId, type, nonce, gasPrice, gasLimit, from, to, value); - this.feePayerSignatureData = new HashSet<>(); - this.feePayer = EMPTY_FEE_PAYER_ADDRESS; + String from, String to, BigInteger value) { + super(chainId, type, nonce, gasPrice, gasLimit, from, to, value); + this.feePayerSignatureData = new HashSet<>(); + this.feePayer = EMPTY_FEE_PAYER_ADDRESS; } public Set getFeePayerSignatureData() { diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedAccountUpdate.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedAccountUpdate.java index 59347bbf2..b7306e1a3 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedAccountUpdate.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedAccountUpdate.java @@ -19,21 +19,25 @@ public class TxTypeFeeDelegatedAccountUpdate extends TxTypeFeeDelegate { */ private final AccountKey accountKey; - public TxTypeFeeDelegatedAccountUpdate(TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, AccountKey accountKey) { + public TxTypeFeeDelegatedAccountUpdate(TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, + String from, AccountKey accountKey) { super(type, nonce, gasPrice, gasLimit, from, "", BigInteger.ZERO); this.accountKey = accountKey; } - public static TxTypeFeeDelegatedAccountUpdate createTransaction(TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, AccountKey accountKey) { + public static TxTypeFeeDelegatedAccountUpdate createTransaction(TxType.Type type, BigInteger nonce, + BigInteger gasPrice, BigInteger gasLimit, String from, AccountKey accountKey) { return new TxTypeFeeDelegatedAccountUpdate(type, nonce, gasPrice, gasLimit, from, accountKey); } - public TxTypeFeeDelegatedAccountUpdate(long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, AccountKey accountKey) { + public TxTypeFeeDelegatedAccountUpdate(long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, + BigInteger gasLimit, String from, AccountKey accountKey) { super(chainId, type, nonce, gasPrice, gasLimit, from, "", BigInteger.ZERO); this.accountKey = accountKey; } - public static TxTypeFeeDelegatedAccountUpdate createTransaction(long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, AccountKey accountKey) { + public static TxTypeFeeDelegatedAccountUpdate createTransaction(long chainId, TxType.Type type, BigInteger nonce, + BigInteger gasPrice, BigInteger gasLimit, String from, AccountKey accountKey) { return new TxTypeFeeDelegatedAccountUpdate(chainId, type, nonce, gasPrice, gasLimit, from, accountKey); } @@ -42,7 +46,8 @@ public AccountKey getAccountKey() { } /** - * create RlpType List which contains nonce, gas price, gas limit, from and accountKey. + * create RlpType List which contains nonce, gas price, gas limit, from and + * accountKey. * List elements can be different depending on transaction type. * * @return List RlpType List @@ -67,13 +72,15 @@ public Type getKaiaType() { } /** - * decode transaction hash from sender to reconstruct transaction with fee payer signature. + * decode transaction hash from sender to reconstruct transaction with fee payer + * signature. * * @param rawTransaction RLP-encoded signed transaction from sender * @return TxTypeFeeDelegatedAccountUpdate decoded transaction */ public static TxTypeFeeDelegatedAccountUpdate decodeFromRawTransaction(byte[] rawTransaction) { - //TxHashRLP = type + encode([nonce, gasPrice, gas, from, rlpEncodedKey, txSignatures, feePayer, feePayerSignatures]) + // TxHashRLP = type + encode([nonce, gasPrice, gas, from, rlpEncodedKey, + // txSignatures, feePayer, feePayerSignatures]) try { byte[] rawTransactionExceptType = KaiaTransactionUtils.getRawTransactionNoType(rawTransaction); @@ -87,8 +94,8 @@ public static TxTypeFeeDelegatedAccountUpdate decodeFromRawTransaction(byte[] ra String accountkeyRaw = ((RlpString) values.get(4)).asString(); TxType.Type type = Type.FEE_DELEGATED_ACCOUNT_UPDATE; - TxTypeFeeDelegatedAccountUpdate tx - = TxTypeFeeDelegatedAccountUpdate.createTransaction(type, nonce, gasPrice, gasLimit, from, AccountKeyDecoder.fromRlp(accountkeyRaw)); + TxTypeFeeDelegatedAccountUpdate tx = TxTypeFeeDelegatedAccountUpdate.createTransaction(type, nonce, + gasPrice, gasLimit, from, AccountKeyDecoder.fromRlp(accountkeyRaw)); tx.addSignatureData(values, 5); return tx; diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedAccountUpdateWithRatio.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedAccountUpdateWithRatio.java index cba6753dc..8a30ccdb1 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedAccountUpdateWithRatio.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedAccountUpdateWithRatio.java @@ -20,29 +20,37 @@ public class TxTypeFeeDelegatedAccountUpdateWithRatio extends TxTypeFeeDelegate private final AccountKey accountKey; /** - * Fee ratio of the fee payer. If it is 30, 30% of the fee will be paid by the fee payer. + * Fee ratio of the fee payer. If it is 30, 30% of the fee will be paid by the + * fee payer. * 70% will be paid by the sender */ private final BigInteger feeRatio; - public TxTypeFeeDelegatedAccountUpdateWithRatio(TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, AccountKey accountKey, BigInteger feeRatio) { + public TxTypeFeeDelegatedAccountUpdateWithRatio(TxType.Type type, BigInteger nonce, BigInteger gasPrice, + BigInteger gasLimit, String from, AccountKey accountKey, BigInteger feeRatio) { super(type, nonce, gasPrice, gasLimit, from, "", BigInteger.ZERO); this.accountKey = accountKey; this.feeRatio = feeRatio; } - public static TxTypeFeeDelegatedAccountUpdateWithRatio createTransaction(TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, AccountKey accountKey, BigInteger feeRatio) { - return new TxTypeFeeDelegatedAccountUpdateWithRatio(type, nonce, gasPrice, gasLimit, from, accountKey, feeRatio); + public static TxTypeFeeDelegatedAccountUpdateWithRatio createTransaction(TxType.Type type, BigInteger nonce, + BigInteger gasPrice, BigInteger gasLimit, String from, AccountKey accountKey, BigInteger feeRatio) { + return new TxTypeFeeDelegatedAccountUpdateWithRatio(type, nonce, gasPrice, gasLimit, from, accountKey, + feeRatio); } - public TxTypeFeeDelegatedAccountUpdateWithRatio(long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, AccountKey accountKey, BigInteger feeRatio) { + public TxTypeFeeDelegatedAccountUpdateWithRatio(long chainId, TxType.Type type, BigInteger nonce, + BigInteger gasPrice, BigInteger gasLimit, String from, AccountKey accountKey, BigInteger feeRatio) { super(chainId, type, nonce, gasPrice, gasLimit, from, "", BigInteger.ZERO); this.accountKey = accountKey; this.feeRatio = feeRatio; } - public static TxTypeFeeDelegatedAccountUpdateWithRatio createTransaction(long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, AccountKey accountKey, BigInteger feeRatio) { - return new TxTypeFeeDelegatedAccountUpdateWithRatio(chainId, type, nonce, gasPrice, gasLimit, from, accountKey, feeRatio); + public static TxTypeFeeDelegatedAccountUpdateWithRatio createTransaction(long chainId, TxType.Type type, + BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, AccountKey accountKey, + BigInteger feeRatio) { + return new TxTypeFeeDelegatedAccountUpdateWithRatio(chainId, type, nonce, gasPrice, gasLimit, from, accountKey, + feeRatio); } public AccountKey getAccountKey() { @@ -54,7 +62,8 @@ public BigInteger getFeeRatio() { } /** - * create RlpType List which contains nonce, gas price, gas limit, from, accountKey and feeRatio. + * create RlpType List which contains nonce, gas price, gas limit, from, + * accountKey and feeRatio. * List elements can be different depending on transaction type. * * @return List RlpType List @@ -80,13 +89,15 @@ public TxType.Type getKaiaType() { } /** - * decode transaction hash from sender to reconstruct transaction with fee payer signature. + * decode transaction hash from sender to reconstruct transaction with fee payer + * signature. * * @param rawTransaction RLP-encoded signed transaction from sender * @return TxTypeFeeDelegatedAccountUpdateWithRatio decoded transaction */ public static TxTypeFeeDelegatedAccountUpdateWithRatio decodeFromRawTransaction(byte[] rawTransaction) { - // TxHashRLP = type + encode([nonce, gasPrice, gas, to, value, from, feeRatio, txSignatures, feePayer, feePayerSignatures]) + // TxHashRLP = type + encode([nonce, gasPrice, gas, to, value, from, feeRatio, + // txSignatures, feePayer, feePayerSignatures]) try { byte[] rawTransactionExceptType = KaiaTransactionUtils.getRawTransactionNoType(rawTransaction); @@ -101,8 +112,8 @@ public static TxTypeFeeDelegatedAccountUpdateWithRatio decodeFromRawTransaction( BigInteger feeRatio = ((RlpString) values.get(5)).asPositiveBigInteger(); TxType.Type type = Type.FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO; - TxTypeFeeDelegatedAccountUpdateWithRatio tx - = TxTypeFeeDelegatedAccountUpdateWithRatio.createTransaction(type, nonce, gasPrice, gasLimit, from, AccountKeyDecoder.fromRlp(accountkeyRaw), feeRatio); + TxTypeFeeDelegatedAccountUpdateWithRatio tx = TxTypeFeeDelegatedAccountUpdateWithRatio.createTransaction( + type, nonce, gasPrice, gasLimit, from, AccountKeyDecoder.fromRlp(accountkeyRaw), feeRatio); tx.addSignatureData(values, 6); return tx; diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedCancel.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedCancel.java index 9daf27428..92a3b8962 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedCancel.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedCancel.java @@ -14,22 +14,22 @@ public class TxTypeFeeDelegatedCancel extends TxTypeFeeDelegate { protected TxTypeFeeDelegatedCancel( - TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from) { + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from) { super(type, nonce, gasPrice, gasLimit, from, "", BigInteger.ZERO); } public static TxTypeFeeDelegatedCancel createTransaction( - TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from) { + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from) { return new TxTypeFeeDelegatedCancel(type, nonce, gasPrice, gasLimit, from); } protected TxTypeFeeDelegatedCancel( - long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from) { + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from) { super(chainId, type, nonce, gasPrice, gasLimit, from, "", BigInteger.ZERO); } public static TxTypeFeeDelegatedCancel createTransaction( - long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from) { + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from) { return new TxTypeFeeDelegatedCancel(chainId, type, nonce, gasPrice, gasLimit, from); } @@ -58,13 +58,15 @@ public Type getKaiaType() { } /** - * decode transaction hash from sender to reconstruct transaction with fee payer signature. + * decode transaction hash from sender to reconstruct transaction with fee payer + * signature. * * @param rawTransaction RLP-encoded signed transaction from sender * @return TxTypeFeeDelegatedCancel decoded transaction */ public static TxTypeFeeDelegatedCancel decodeFromRawTransaction(byte[] rawTransaction) { - //TxHashRLP = type + encode([nonce, gasPrice, gas, from, txSignatures, feePayer, feePayerSignatures]) + // TxHashRLP = type + encode([nonce, gasPrice, gas, from, txSignatures, + // feePayer, feePayerSignatures]) try { byte[] rawTransactionExceptType = KaiaTransactionUtils.getRawTransactionNoType(rawTransaction); @@ -74,10 +76,10 @@ public static TxTypeFeeDelegatedCancel decodeFromRawTransaction(byte[] rawTransa BigInteger gasPrice = ((RlpString) values.get(1)).asPositiveBigInteger(); BigInteger gasLimit = ((RlpString) values.get(2)).asPositiveBigInteger(); String from = ((RlpString) values.get(3)).asString(); - TxType.Type type= Type.FEE_DELEGATED_CANCEL; + TxType.Type type = Type.FEE_DELEGATED_CANCEL; - TxTypeFeeDelegatedCancel tx - = TxTypeFeeDelegatedCancel.createTransaction(type, nonce, gasPrice, gasLimit, from); + TxTypeFeeDelegatedCancel tx = TxTypeFeeDelegatedCancel.createTransaction(type, nonce, gasPrice, gasLimit, + from); tx.addSignatureData(values, 4); return tx; } catch (Exception e) { diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedCancelWithRatio.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedCancelWithRatio.java index 4e796820e..f9868a8e9 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedCancelWithRatio.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedCancelWithRatio.java @@ -11,34 +11,38 @@ import org.web3j.utils.KaiaTransactionUtils; import org.web3j.utils.Numeric; - -public class TxTypeFeeDelegatedCancelWithRatio extends TxTypeFeeDelegate { +public class TxTypeFeeDelegatedCancelWithRatio extends TxTypeFeeDelegate { /** - * Fee ratio of the fee payer. If it is 30, 30% of the fee will be paid by the fee payer. + * Fee ratio of the fee payer. If it is 30, 30% of the fee will be paid by the + * fee payer. * 70% will be paid by the sender. */ private final BigInteger feeRatio; protected TxTypeFeeDelegatedCancelWithRatio( - TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, BigInteger feeRatio) { + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, + BigInteger feeRatio) { super(type, nonce, gasPrice, gasLimit, from, "", BigInteger.ZERO); this.feeRatio = feeRatio; } public static TxTypeFeeDelegatedCancelWithRatio createTransaction( - TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, BigInteger feeRatio) { + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, + BigInteger feeRatio) { return new TxTypeFeeDelegatedCancelWithRatio(type, nonce, gasPrice, gasLimit, from, feeRatio); } protected TxTypeFeeDelegatedCancelWithRatio( - long chainId, TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, BigInteger feeRatio) { + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, + BigInteger feeRatio) { super(chainId, type, nonce, gasPrice, gasLimit, from, "", BigInteger.ZERO); this.feeRatio = feeRatio; } public static TxTypeFeeDelegatedCancelWithRatio createTransaction( - long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, BigInteger feeRatio) { + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, + BigInteger feeRatio) { return new TxTypeFeeDelegatedCancelWithRatio(chainId, type, nonce, gasPrice, gasLimit, from, feeRatio); } @@ -47,7 +51,8 @@ public BigInteger getFeeRatio() { } /** - * create RlpType List which contains nonce, gas price, gas limit, from and feeRatio. + * create RlpType List which contains nonce, gas price, gas limit, from and + * feeRatio. * List elements can be different depending on transaction type. * * @return List RlpType List @@ -72,13 +77,15 @@ public TxType.Type getKaiaType() { } /** - * decode transaction hash from sender to reconstruct transaction with fee payer signature. + * decode transaction hash from sender to reconstruct transaction with fee payer + * signature. * * @param rawTransaction RLP-encoded signed transaction from sender * @return TxTypeFeeDelegatedCancelWithRatio decoded transaction */ public static TxTypeFeeDelegatedCancelWithRatio decodeFromRawTransaction(byte[] rawTransaction) { - //TxHashRLP = type + encode([nonce, gasPrice, gas, from, feeRatio, txSignatures, feePayer, feePayerSignatures]) + // TxHashRLP = type + encode([nonce, gasPrice, gas, from, feeRatio, + // txSignatures, feePayer, feePayerSignatures]) try { byte[] rawTransactionExceptType = KaiaTransactionUtils.getRawTransactionNoType(rawTransaction); @@ -91,8 +98,8 @@ public static TxTypeFeeDelegatedCancelWithRatio decodeFromRawTransaction(byte[] BigInteger feeRatio = ((RlpString) values.get(4)).asPositiveBigInteger(); TxType.Type type = Type.FEE_DELEGATED_CANCEL_WITH_RATIO; - TxTypeFeeDelegatedCancelWithRatio tx - = TxTypeFeeDelegatedCancelWithRatio.createTransaction(type, nonce, gasPrice, gasLimit, from, feeRatio); + TxTypeFeeDelegatedCancelWithRatio tx = TxTypeFeeDelegatedCancelWithRatio.createTransaction(type, nonce, + gasPrice, gasLimit, from, feeRatio); tx.addSignatureData(values, 5); return tx; } catch (Exception e) { @@ -108,8 +115,6 @@ public static TxTypeFeeDelegatedCancelWithRatio decodeFromRawTransaction(String return decodeFromRawTransaction(Numeric.hexStringToByteArray(Numeric.cleanHexPrefix(rawTransaction))); } - - @Override public List asRlpValues(SignatureData signatureData) { // TODO Auto-generated method stub diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedChainDataAnchoring.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedChainDataAnchoring.java index 3be574144..4ad137595 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedChainDataAnchoring.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedChainDataAnchoring.java @@ -13,11 +13,11 @@ /** * Transaction class used for signing 1559 transactions locally.
- * For the specification, refer to p4 of the yellow + * For the specification, refer to p4 of the + * yellow * paper. */ -public class TxTypeFeeDelegatedChainDataAnchoring extends TxTypeFeeDelegate { - +public class TxTypeFeeDelegatedChainDataAnchoring extends TxTypeFeeDelegate { /** * data of the child chain @@ -25,24 +25,28 @@ public class TxTypeFeeDelegatedChainDataAnchoring extends TxTypeFeeDelegate { private final byte[] anchoredData; protected TxTypeFeeDelegatedChainDataAnchoring( - TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, byte[] anchoredData) { + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, + byte[] anchoredData) { super(type, nonce, gasPrice, gasLimit, from, "", BigInteger.ZERO); this.anchoredData = anchoredData; } public static TxTypeFeeDelegatedChainDataAnchoring createTransaction( - TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, byte[] anchoredData) { + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, + byte[] anchoredData) { return new TxTypeFeeDelegatedChainDataAnchoring(type, nonce, gasPrice, gasLimit, from, anchoredData); } protected TxTypeFeeDelegatedChainDataAnchoring( - long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, byte[] anchoredData) { + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, + byte[] anchoredData) { super(chainId, type, nonce, gasPrice, gasLimit, from, "", BigInteger.ZERO); this.anchoredData = anchoredData; } public static TxTypeFeeDelegatedChainDataAnchoring createTransaction( - long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, byte[] anchoredData) { + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, + byte[] anchoredData) { return new TxTypeFeeDelegatedChainDataAnchoring(chainId, type, nonce, gasPrice, gasLimit, from, anchoredData); } @@ -51,7 +55,8 @@ public byte[] getAnchoredData() { } /** - * create RlpType List which contains nonce, gas price, gas limit, to, value, from and anchoredData. + * create RlpType List which contains nonce, gas price, gas limit, to, value, + * from and anchoredData. * List elements can be different depending on transaction type. * * @return List RlpType List @@ -76,7 +81,8 @@ public Type getKaiaType() { } /** - * decode transaction hash from sender to reconstruct transaction with fee payer signature. + * decode transaction hash from sender to reconstruct transaction with fee payer + * signature. * * @param rawTransaction RLP-encoded signed transaction from sender * @return TxTypeChainDataAnchoringTransaction decoded transaction @@ -91,14 +97,13 @@ public static TxTypeFeeDelegatedChainDataAnchoring decodeFromRawTransaction(byte BigInteger gasLimit = ((RlpString) values.get(2)).asPositiveBigInteger(); String from = ((RlpString) values.get(3)).asString(); byte[] payload = ((RlpString) values.get(4)).getBytes(); - TxType.Type type= Type.FEE_DELEGATED_CHAIN_DATA_ANCHORING; + TxType.Type type = Type.FEE_DELEGATED_CHAIN_DATA_ANCHORING; - TxTypeFeeDelegatedChainDataAnchoring tx - = new TxTypeFeeDelegatedChainDataAnchoring(type, nonce, gasPrice, gasLimit, from, payload); + TxTypeFeeDelegatedChainDataAnchoring tx = new TxTypeFeeDelegatedChainDataAnchoring(type, nonce, gasPrice, + gasLimit, from, payload); tx.addSignatureData(values, 5); return tx; } - /** * @param rawTransaction RLP-encoded signed transaction from sender @@ -108,22 +113,22 @@ public static TxTypeFeeDelegatedChainDataAnchoring decodeFromRawTransaction(Stri return decodeFromRawTransaction(Numeric.hexStringToByteArray(Numeric.cleanHexPrefix(rawTransaction))); } - @Override - public List asRlpValues(SignatureData signatureData) { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getData() { - // TODO Auto-generated method stub - return null; - } - - @Override - public TransactionType getType() { - // TODO Auto-generated method stub - return null; - } + @Override + public List asRlpValues(SignatureData signatureData) { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getData() { + // TODO Auto-generated method stub + return null; + } + + @Override + public TransactionType getType() { + // TODO Auto-generated method stub + return null; + } } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedChainDataAnchoringWithRatio.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedChainDataAnchoringWithRatio.java index 13b55f1a9..7c9f6b5f6 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedChainDataAnchoringWithRatio.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedChainDataAnchoringWithRatio.java @@ -13,14 +13,12 @@ /** * Transaction class used for signing 1559 transactions locally.
- * For the specification, refer to p4 of the yellow + * For the specification, refer to p4 of the + * yellow * paper. */ -public class TxTypeFeeDelegatedChainDataAnchoringWithRatio extends TxTypeFeeDelegate { +public class TxTypeFeeDelegatedChainDataAnchoringWithRatio extends TxTypeFeeDelegate { - - - /** * data of the child chain */ @@ -28,27 +26,33 @@ public class TxTypeFeeDelegatedChainDataAnchoringWithRatio extends TxTypeFeeDele private final BigInteger feeRatio; protected TxTypeFeeDelegatedChainDataAnchoringWithRatio( - TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, byte[] anchoredData, BigInteger feeRatio) { + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, + byte[] anchoredData, BigInteger feeRatio) { super(type, nonce, gasPrice, gasLimit, from, "", BigInteger.ZERO); this.anchoredData = anchoredData; this.feeRatio = feeRatio; } public static TxTypeFeeDelegatedChainDataAnchoringWithRatio createTransaction( - TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, byte[] anchoredData, BigInteger feeRatio) { - return new TxTypeFeeDelegatedChainDataAnchoringWithRatio(type, nonce, gasPrice, gasLimit, from, anchoredData, feeRatio); + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, + byte[] anchoredData, BigInteger feeRatio) { + return new TxTypeFeeDelegatedChainDataAnchoringWithRatio(type, nonce, gasPrice, gasLimit, from, anchoredData, + feeRatio); } protected TxTypeFeeDelegatedChainDataAnchoringWithRatio( - long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, byte[] anchoredData, BigInteger feeRatio) { + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, + byte[] anchoredData, BigInteger feeRatio) { super(chainId, type, nonce, gasPrice, gasLimit, from, "", BigInteger.ZERO); this.anchoredData = anchoredData; this.feeRatio = feeRatio; } public static TxTypeFeeDelegatedChainDataAnchoringWithRatio createTransaction( - long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, byte[] anchoredData, BigInteger feeRatio) { - return new TxTypeFeeDelegatedChainDataAnchoringWithRatio(chainId, type, nonce, gasPrice, gasLimit, from, anchoredData, feeRatio); + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String from, + byte[] anchoredData, BigInteger feeRatio) { + return new TxTypeFeeDelegatedChainDataAnchoringWithRatio(chainId, type, nonce, gasPrice, gasLimit, from, + anchoredData, feeRatio); } public byte[] getAnchoredData() { @@ -56,7 +60,8 @@ public byte[] getAnchoredData() { } /** - * create RlpType List which contains nonce, gas price, gas limit, to, value, from and anchoredData. + * create RlpType List which contains nonce, gas price, gas limit, to, value, + * from and anchoredData. * List elements can be different depending on transaction type. * * @return List RlpType List @@ -81,7 +86,8 @@ public Type getKaiaType() { } /** - * decode transaction hash from sender to reconstruct transaction with fee payer signature. + * decode transaction hash from sender to reconstruct transaction with fee payer + * signature. * * @param rawTransaction RLP-encoded signed transaction from sender * @return TxTypeChainDataAnchoringTransaction decoded transaction @@ -97,14 +103,13 @@ public static TxTypeFeeDelegatedChainDataAnchoringWithRatio decodeFromRawTransac String from = ((RlpString) values.get(3)).asString(); byte[] payload = ((RlpString) values.get(4)).getBytes(); BigInteger feeRatio = ((RlpString) values.get(5)).asPositiveBigInteger(); - TxType.Type type= Type.FEE_DELEGATED_CHAIN_DATA_ANCHORING_WITH_RATIO; + TxType.Type type = Type.FEE_DELEGATED_CHAIN_DATA_ANCHORING_WITH_RATIO; - TxTypeFeeDelegatedChainDataAnchoringWithRatio tx - = new TxTypeFeeDelegatedChainDataAnchoringWithRatio(type, nonce, gasPrice, gasLimit, from, payload, feeRatio); + TxTypeFeeDelegatedChainDataAnchoringWithRatio tx = new TxTypeFeeDelegatedChainDataAnchoringWithRatio(type, + nonce, gasPrice, gasLimit, from, payload, feeRatio); tx.addSignatureData(values, 6); return tx; } - /** * @param rawTransaction RLP-encoded signed transaction from sender @@ -114,22 +119,22 @@ public static TxTypeFeeDelegatedChainDataAnchoringWithRatio decodeFromRawTransac return decodeFromRawTransaction(Numeric.hexStringToByteArray(Numeric.cleanHexPrefix(rawTransaction))); } - @Override - public List asRlpValues(SignatureData signatureData) { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getData() { - // TODO Auto-generated method stub - return null; - } - - @Override - public TransactionType getType() { - // TODO Auto-generated method stub - return null; - } + @Override + public List asRlpValues(SignatureData signatureData) { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getData() { + // TODO Auto-generated method stub + return null; + } + + @Override + public TransactionType getType() { + // TODO Auto-generated method stub + return null; + } } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedSmartContractDeploy.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedSmartContractDeploy.java index ea270e397..e0f3797f4 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedSmartContractDeploy.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedSmartContractDeploy.java @@ -21,7 +21,7 @@ public class TxTypeFeeDelegatedSmartContractDeploy extends TxTypeFeeDelegate { private final BigInteger codeFormat; public TxTypeFeeDelegatedSmartContractDeploy( - TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, BigInteger value, + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, BigInteger value, String from, byte[] payload, BigInteger codeFormat) { super(type, nonce, gasPrice, gasLimit, from, "", value); this.payload = payload; @@ -29,13 +29,15 @@ public TxTypeFeeDelegatedSmartContractDeploy( } public static TxTypeFeeDelegatedSmartContractDeploy createTransaction( - TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, BigInteger value, String from, byte[] payload, BigInteger codeFormat) { - return new TxTypeFeeDelegatedSmartContractDeploy(type, nonce, gasPrice, gasLimit, value, from, payload, codeFormat); + return new TxTypeFeeDelegatedSmartContractDeploy(type, nonce, gasPrice, gasLimit, value, from, payload, + codeFormat); } public TxTypeFeeDelegatedSmartContractDeploy( - long chainId, TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, BigInteger value, + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, + BigInteger value, String from, byte[] payload, BigInteger codeFormat) { super(chainId, type, nonce, gasPrice, gasLimit, from, "", value); this.payload = payload; @@ -43,9 +45,10 @@ public TxTypeFeeDelegatedSmartContractDeploy( } public static TxTypeFeeDelegatedSmartContractDeploy createTransaction( - long chainId, TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, BigInteger value, String from, byte[] payload, BigInteger codeFormat) { - return new TxTypeFeeDelegatedSmartContractDeploy(chainId, type, nonce, gasPrice, gasLimit, value, from, payload, codeFormat); + return new TxTypeFeeDelegatedSmartContractDeploy(chainId, type, nonce, gasPrice, gasLimit, value, from, payload, + codeFormat); } public byte[] getPayload() { @@ -57,7 +60,8 @@ public BigInteger getCodeFormat() { } /** - * create RlpType List which contains nonce, gas price, gas limit, to, value, from, payload and isHumanReadable. + * create RlpType List which contains nonce, gas price, gas limit, to, value, + * from, payload and isHumanReadable. * List elements can be different depending on transaction type. * * @return List RlpType List @@ -86,13 +90,15 @@ public Type getKaiaType() { } /** - * decode transaction hash from sender to reconstruct transaction with fee payer signature. + * decode transaction hash from sender to reconstruct transaction with fee payer + * signature. * * @param rawTransaction RLP-encoded signed transaction from sender * @return TxTypeFeeDelegatedSmartContractDeploy decoded transaction */ public static TxTypeFeeDelegatedSmartContractDeploy decodeFromRawTransaction(byte[] rawTransaction) { - //TxHashRLP = type + encode([nonce, gasPrice, gas, to, value, from, input, humanReadable, codeFormat, txSignatures, feePayer, feePayerSignatures]) + // TxHashRLP = type + encode([nonce, gasPrice, gas, to, value, from, input, + // humanReadable, codeFormat, txSignatures, feePayer, feePayerSignatures]) try { byte[] rawTransactionExceptType = KaiaTransactionUtils.getRawTransactionNoType(rawTransaction); @@ -107,8 +113,8 @@ public static TxTypeFeeDelegatedSmartContractDeploy decodeFromRawTransaction(byt BigInteger codeFormat = ((RlpString) values.get(8)).asPositiveBigInteger(); TxType.Type type = Type.FEE_DELEGATED_SMART_CONTRACT_DEPLOY; - TxTypeFeeDelegatedSmartContractDeploy tx - = new TxTypeFeeDelegatedSmartContractDeploy(type, nonce, gasPrice, gasLimit, value, from, payload, codeFormat); + TxTypeFeeDelegatedSmartContractDeploy tx = new TxTypeFeeDelegatedSmartContractDeploy(type, nonce, gasPrice, + gasLimit, value, from, payload, codeFormat); tx.addSignatureData(values, 9); return tx; } catch (Exception e) { @@ -124,7 +130,6 @@ public static TxTypeFeeDelegatedSmartContractDeploy decodeFromRawTransaction(Str return decodeFromRawTransaction(Numeric.hexStringToByteArray(Numeric.cleanHexPrefix(rawTransaction))); } - @Override public List asRlpValues(SignatureData signatureData) { // TODO Auto-generated method stub diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedSmartContractDeployWithRatio.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedSmartContractDeployWithRatio.java index 2bf115de6..280016ba3 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedSmartContractDeployWithRatio.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedSmartContractDeployWithRatio.java @@ -19,7 +19,8 @@ public class TxTypeFeeDelegatedSmartContractDeployWithRatio extends TxTypeFeeDel private final byte[] payload; /** - * Fee ratio of the fee payer. If it is 30, 30% of the fee will be paid by the fee payer. + * Fee ratio of the fee payer. If it is 30, 30% of the fee will be paid by the + * fee payer. * 70% will be paid by the sender. */ private final BigInteger feeRatio; @@ -30,7 +31,7 @@ public class TxTypeFeeDelegatedSmartContractDeployWithRatio extends TxTypeFeeDel private final BigInteger codeFormat; public TxTypeFeeDelegatedSmartContractDeployWithRatio( - TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, BigInteger value, + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, BigInteger value, String from, byte[] payload, BigInteger feeRatio, BigInteger codeFormat) { super(type, nonce, gasPrice, gasLimit, from, "", value); this.payload = payload; @@ -39,13 +40,15 @@ public TxTypeFeeDelegatedSmartContractDeployWithRatio( } public static TxTypeFeeDelegatedSmartContractDeployWithRatio createTransaction( - TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, BigInteger value, + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, BigInteger value, String from, byte[] payload, BigInteger feeRatio, BigInteger codeFormat) { - return new TxTypeFeeDelegatedSmartContractDeployWithRatio(type, nonce, gasPrice, gasLimit, value, from, payload, feeRatio, codeFormat); + return new TxTypeFeeDelegatedSmartContractDeployWithRatio(type, nonce, gasPrice, gasLimit, value, from, payload, + feeRatio, codeFormat); } public TxTypeFeeDelegatedSmartContractDeployWithRatio( - long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, BigInteger value, + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, + BigInteger value, String from, byte[] payload, BigInteger feeRatio, BigInteger codeFormat) { super(chainId, type, nonce, gasPrice, gasLimit, from, "", value); this.payload = payload; @@ -54,10 +57,13 @@ public TxTypeFeeDelegatedSmartContractDeployWithRatio( } public static TxTypeFeeDelegatedSmartContractDeployWithRatio createTransaction( - long chainId, TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, BigInteger value, + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, + BigInteger value, String from, byte[] payload, BigInteger feeRatio, BigInteger codeFormat) { - return new TxTypeFeeDelegatedSmartContractDeployWithRatio(chainId, type, nonce, gasPrice, gasLimit, value, from, payload, feeRatio, codeFormat); + return new TxTypeFeeDelegatedSmartContractDeployWithRatio(chainId, type, nonce, gasPrice, gasLimit, value, from, + payload, feeRatio, codeFormat); } + public byte[] getPayload() { return payload; } @@ -71,7 +77,8 @@ public BigInteger getCodeFormat() { } /** - * create RlpType List which contains nonce, gas price, gas limit, to, value, from, payload, isHumanReadable and feeRatio. + * create RlpType List which contains nonce, gas price, gas limit, to, value, + * from, payload, isHumanReadable and feeRatio. * List elements can be different depending on transaction type. * * @return List RlpType List @@ -90,7 +97,8 @@ public List rlpValues() { } /** - * This method is overridden as FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO type. + * This method is overridden as FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO + * type. * The return value is used for rlp encoding. * * @return Type transaction type @@ -101,13 +109,16 @@ public Type getKaiaType() { } /** - * decode transaction hash from sender to reconstruct transaction with fee payer signature. + * decode transaction hash from sender to reconstruct transaction with fee payer + * signature. * * @param rawTransaction RLP-encoded signed transaction from sender * @return TxTypeFeeDelegatedSmartContractDeployWithRatio decoded transaction */ public static TxTypeFeeDelegatedSmartContractDeployWithRatio decodeFromRawTransaction(byte[] rawTransaction) { - // TxHashRLP = type + encode([nonce, gasPrice, gas, to, value, from, input, humanReadable, feeRatio, codeFormat, txSignatures, feePayer, feePayerSignatures]) + // TxHashRLP = type + encode([nonce, gasPrice, gas, to, value, from, input, + // humanReadable, feeRatio, codeFormat, txSignatures, feePayer, + // feePayerSignatures]) try { byte[] rawTransactionExceptType = KaiaTransactionUtils.getRawTransactionNoType(rawTransaction); @@ -122,8 +133,8 @@ public static TxTypeFeeDelegatedSmartContractDeployWithRatio decodeFromRawTransa BigInteger feeRatio = ((RlpString) values.get(8)).asPositiveBigInteger(); BigInteger codeFormat = ((RlpString) values.get(9)).asPositiveBigInteger(); TxType.Type type = Type.FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO; - TxTypeFeeDelegatedSmartContractDeployWithRatio tx - = new TxTypeFeeDelegatedSmartContractDeployWithRatio(type, nonce, gasPrice, gasLimit, value, from, payload, feeRatio, codeFormat); + TxTypeFeeDelegatedSmartContractDeployWithRatio tx = new TxTypeFeeDelegatedSmartContractDeployWithRatio(type, + nonce, gasPrice, gasLimit, value, from, payload, feeRatio, codeFormat); tx.addSignatureData(values, 10); return tx; } catch (Exception e) { diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedSmartContractExecution.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedSmartContractExecution.java index 642da29f6..6aa997464 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedSmartContractExecution.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedSmartContractExecution.java @@ -19,36 +19,39 @@ public class TxTypeFeeDelegatedSmartContractExecution extends TxTypeFeeDelegate private final byte[] payload; protected TxTypeFeeDelegatedSmartContractExecution( - TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload) { super(type, nonce, gasPrice, gasLimit, from, to, value); this.payload = payload; } public static TxTypeFeeDelegatedSmartContractExecution createTransaction( - TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload) { return new TxTypeFeeDelegatedSmartContractExecution(type, nonce, gasPrice, gasLimit, to, value, from, payload); } protected TxTypeFeeDelegatedSmartContractExecution( - long chainId, TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload) { super(chainId, type, nonce, gasPrice, gasLimit, from, to, value); this.payload = payload; } public static TxTypeFeeDelegatedSmartContractExecution createTransaction( - long chainId, TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload) { - return new TxTypeFeeDelegatedSmartContractExecution(chainId, type, nonce, gasPrice, gasLimit, to, value, from, payload); + return new TxTypeFeeDelegatedSmartContractExecution(chainId, type, nonce, gasPrice, gasLimit, to, value, from, + payload); } + public byte[] getPayload() { return payload; } /** - * create RlpType List which contains nonce, gas price, gas limit, to, value, from and payload. + * create RlpType List which contains nonce, gas price, gas limit, to, value, + * from and payload. * List elements can be different depending on transaction type. * * @return List RlpType List @@ -75,7 +78,8 @@ public Type getKaiaType() { } /** - * decode transaction hash from sender to reconstruct transaction with fee payer signature. + * decode transaction hash from sender to reconstruct transaction with fee payer + * signature. * * @param rawTransaction RLP-encoded signed transaction from sender * @return TxTypeFeeDelegatedSmartContractExecution decoded transaction @@ -95,8 +99,8 @@ public static TxTypeFeeDelegatedSmartContractExecution decodeFromRawTransaction( byte[] payload = ((RlpString) values.get(6)).getBytes(); TxType.Type type = Type.FEE_DELEGATED_SMART_CONTRACT_EXECUTION; - TxTypeFeeDelegatedSmartContractExecution tx - = TxTypeFeeDelegatedSmartContractExecution.createTransaction(type, nonce, gasPrice, gasLimit, to, value, from, payload); + TxTypeFeeDelegatedSmartContractExecution tx = TxTypeFeeDelegatedSmartContractExecution + .createTransaction(type, nonce, gasPrice, gasLimit, to, value, from, payload); tx.addSignatureData(values, 7); return tx; } catch (Exception e) { diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedSmartContractExecutionWithRatio.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedSmartContractExecutionWithRatio.java index 29e0beea7..280431359 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedSmartContractExecutionWithRatio.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedSmartContractExecutionWithRatio.java @@ -18,13 +18,14 @@ public class TxTypeFeeDelegatedSmartContractExecutionWithRatio extends TxTypeFee private final byte[] payload; /** - * Fee ratio of the fee payer. If it is 30, 30% of the fee will be paid by the fee payer. + * Fee ratio of the fee payer. If it is 30, 30% of the fee will be paid by the + * fee payer. * 70% will be paid by the sender. */ private final BigInteger feeRatio; protected TxTypeFeeDelegatedSmartContractExecutionWithRatio( - TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload, BigInteger feeRatio) { super(type, nonce, gasPrice, gasLimit, from, to, value); this.payload = payload; @@ -32,13 +33,14 @@ protected TxTypeFeeDelegatedSmartContractExecutionWithRatio( } public static TxTypeFeeDelegatedSmartContractExecutionWithRatio createTransaction( - TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload, BigInteger feeRatio) { - return new TxTypeFeeDelegatedSmartContractExecutionWithRatio(type, nonce, gasPrice, gasLimit, to, value, from, payload, feeRatio); + return new TxTypeFeeDelegatedSmartContractExecutionWithRatio(type, nonce, gasPrice, gasLimit, to, value, from, + payload, feeRatio); } protected TxTypeFeeDelegatedSmartContractExecutionWithRatio( - long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload, BigInteger feeRatio) { super(type, nonce, gasPrice, gasLimit, from, to, value); this.payload = payload; @@ -46,10 +48,12 @@ protected TxTypeFeeDelegatedSmartContractExecutionWithRatio( } public static TxTypeFeeDelegatedSmartContractExecutionWithRatio createTransaction( - long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload, BigInteger feeRatio) { - return new TxTypeFeeDelegatedSmartContractExecutionWithRatio(chainId, type, nonce, gasPrice, gasLimit, to, value, from, payload, feeRatio); + return new TxTypeFeeDelegatedSmartContractExecutionWithRatio(chainId, type, nonce, gasPrice, gasLimit, to, + value, from, payload, feeRatio); } + public byte[] getPayload() { return payload; } @@ -59,7 +63,8 @@ public BigInteger getFeeRatio() { } /** - * create RlpType List which contains nonce, gas price, gas limit, to, value, from, payload and feeRatio. + * create RlpType List which contains nonce, gas price, gas limit, to, value, + * from, payload and feeRatio. * List elements can be different depending on transaction type. * * @return List RlpType List @@ -76,7 +81,8 @@ public List rlpValues() { } /** - * This method is overridden as FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO type. + * This method is overridden as + * FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO type. * The return value is used for rlp encoding. * * @return Type transaction type @@ -87,13 +93,15 @@ public TxType.Type getKaiaType() { } /** - * decode transaction hash from sender to reconstruct transaction with fee payer signature. + * decode transaction hash from sender to reconstruct transaction with fee payer + * signature. * * @param rawTransaction RLP-encoded signed transaction from sender * @return TxTypeFeeDelegatedSmartContractExecutionWithRatio decoded transaction */ public static TxTypeFeeDelegatedSmartContractExecutionWithRatio decodeFromRawTransaction(byte[] rawTransaction) { - // TxHashRLP = type + encode([nonce, gasPrice, gas, to, value, from, input, txSignatures]) + // TxHashRLP = type + encode([nonce, gasPrice, gas, to, value, from, input, + // txSignatures]) try { byte[] rawTransactionExceptType = KaiaTransactionUtils.getRawTransactionNoType(rawTransaction); @@ -108,8 +116,8 @@ public static TxTypeFeeDelegatedSmartContractExecutionWithRatio decodeFromRawTra byte[] payload = ((RlpString) values.get(6)).getBytes(); BigInteger feeRatio = ((RlpString) values.get(7)).asPositiveBigInteger(); TxType.Type type = Type.FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO; - TxTypeFeeDelegatedSmartContractExecutionWithRatio tx - = TxTypeFeeDelegatedSmartContractExecutionWithRatio.createTransaction(type, nonce, gasPrice, gasLimit, to, value, from, payload, feeRatio); + TxTypeFeeDelegatedSmartContractExecutionWithRatio tx = TxTypeFeeDelegatedSmartContractExecutionWithRatio + .createTransaction(type, nonce, gasPrice, gasLimit, to, value, from, payload, feeRatio); tx.addSignatureData(values, 8); return tx; } catch (Exception e) { diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedValueTransfer.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedValueTransfer.java index a4fc746be..b7eff3743 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedValueTransfer.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedValueTransfer.java @@ -11,7 +11,7 @@ import org.web3j.utils.KaiaTransactionUtils; import org.web3j.utils.Numeric; -public class TxTypeFeeDelegatedValueTransfer extends TxTypeFeeDelegate { +public class TxTypeFeeDelegatedValueTransfer extends TxTypeFeeDelegate { protected TxTypeFeeDelegatedValueTransfer(TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from) { @@ -30,7 +30,7 @@ protected TxTypeFeeDelegatedValueTransfer(long chainId, TxType.Type type, BigInt } public static TxTypeFeeDelegatedValueTransfer createTransaction( - long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String recipient, BigInteger value, String from) { return new TxTypeFeeDelegatedValueTransfer(chainId, type, nonce, gasPrice, gasLimit, recipient, value, from); } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedValueTransferMemo.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedValueTransferMemo.java index 7419b5e8d..098aa9b94 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedValueTransferMemo.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedValueTransferMemo.java @@ -18,22 +18,30 @@ public class TxTypeFeeDelegatedValueTransferMemo extends TxTypeFeeDelegate { */ private final byte[] payload; - protected TxTypeFeeDelegatedValueTransferMemo(TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload) { + protected TxTypeFeeDelegatedValueTransferMemo(TxType.Type type, BigInteger nonce, BigInteger gasPrice, + BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload) { super(type, nonce, gasPrice, gasLimit, from, to, value); this.payload = payload; } - public static TxTypeFeeDelegatedValueTransferMemo createTransaction(TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload) { + public static TxTypeFeeDelegatedValueTransferMemo createTransaction(TxType.Type type, BigInteger nonce, + BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload) { return new TxTypeFeeDelegatedValueTransferMemo(type, nonce, gasPrice, gasLimit, to, value, from, payload); } - protected TxTypeFeeDelegatedValueTransferMemo(long chainId, TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload) { + + protected TxTypeFeeDelegatedValueTransferMemo(long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, + BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload) { super(chainId, type, nonce, gasPrice, gasLimit, from, to, value); this.payload = payload; } - public static TxTypeFeeDelegatedValueTransferMemo createTransaction(long chainId, TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload) { - return new TxTypeFeeDelegatedValueTransferMemo(chainId, type, nonce, gasPrice, gasLimit, to, value, from, payload); + public static TxTypeFeeDelegatedValueTransferMemo createTransaction(long chainId, TxType.Type type, + BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, + byte[] payload) { + return new TxTypeFeeDelegatedValueTransferMemo(chainId, type, nonce, gasPrice, gasLimit, to, value, from, + payload); } + public byte[] getPayload() { return payload; } @@ -50,7 +58,8 @@ public Type getKaiaType() { } /** - * create RlpType List which contains nonce, gas price, gas limit, to, value, from and payload. + * create RlpType List which contains nonce, gas price, gas limit, to, value, + * from and payload. * List elements can be different depending on transaction type. * * @return List RlpType List @@ -66,13 +75,15 @@ public List rlpValues() { } /** - * decode transaction hash from sender to reconstruct transaction with fee payer signature. + * decode transaction hash from sender to reconstruct transaction with fee payer + * signature. * * @param rawTransaction RLP-encoded signed transaction from sender * @return TxTypeFeeDelegatedValueTransferMemo decoded transaction */ public static TxTypeFeeDelegatedValueTransferMemo decodeFromRawTransaction(byte[] rawTransaction) { - // TxHashRLP = type + encode([nonce, gasPrice, gas, to, value, from, input, txSignatures, feePayer, feePayerSignatures]) + // TxHashRLP = type + encode([nonce, gasPrice, gas, to, value, from, input, + // txSignatures, feePayer, feePayerSignatures]) try { byte[] rawTransactionExceptType = KaiaTransactionUtils.getRawTransactionNoType(rawTransaction); @@ -86,8 +97,8 @@ public static TxTypeFeeDelegatedValueTransferMemo decodeFromRawTransaction(byte[ String from = ((RlpString) values.get(5)).asString(); byte[] payload = ((RlpString) values.get(6)).getBytes(); TxType.Type type = Type.FEE_DELEGATED_VALUE_TRANSFER_MEMO; - TxTypeFeeDelegatedValueTransferMemo tx - = TxTypeFeeDelegatedValueTransferMemo.createTransaction(type, nonce, gasPrice, gasLimit, to, value, from, payload); + TxTypeFeeDelegatedValueTransferMemo tx = TxTypeFeeDelegatedValueTransferMemo.createTransaction(type, nonce, + gasPrice, gasLimit, to, value, from, payload); tx.addSignatureData(values, 7); return tx; } catch (Exception e) { diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedValueTransferMemoWithRatio.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedValueTransferMemoWithRatio.java index e04fae9d8..cdfb5a42d 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedValueTransferMemoWithRatio.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedValueTransferMemoWithRatio.java @@ -19,32 +19,42 @@ public class TxTypeFeeDelegatedValueTransferMemoWithRatio extends TxTypeFeeDeleg private final byte[] payload; /** - * Fee ratio of the fee payer. If it is 30, 30% of the fee will be paid by the fee payer. + * Fee ratio of the fee payer. If it is 30, 30% of the fee will be paid by the + * fee payer. * 70% will be paid by the sender. */ private final BigInteger feeRatio; - protected TxTypeFeeDelegatedValueTransferMemoWithRatio(TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, - String to, BigInteger value, String from, byte[] payload, BigInteger feeRatio) { + protected TxTypeFeeDelegatedValueTransferMemoWithRatio(TxType.Type type, BigInteger nonce, BigInteger gasPrice, + BigInteger gasLimit, + String to, BigInteger value, String from, byte[] payload, BigInteger feeRatio) { super(type, nonce, gasPrice, gasLimit, from, to, value); this.payload = payload; this.feeRatio = feeRatio; } - public static TxTypeFeeDelegatedValueTransferMemoWithRatio createTransaction(TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload, BigInteger feeRatio) { - return new TxTypeFeeDelegatedValueTransferMemoWithRatio(type, nonce, gasPrice, gasLimit, to, value, from, payload, feeRatio); + public static TxTypeFeeDelegatedValueTransferMemoWithRatio createTransaction(TxType.Type type, BigInteger nonce, + BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload, + BigInteger feeRatio) { + return new TxTypeFeeDelegatedValueTransferMemoWithRatio(type, nonce, gasPrice, gasLimit, to, value, from, + payload, feeRatio); } - protected TxTypeFeeDelegatedValueTransferMemoWithRatio(long chainId, TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, - String to, BigInteger value, String from, byte[] payload, BigInteger feeRatio) { + protected TxTypeFeeDelegatedValueTransferMemoWithRatio(long chainId, TxType.Type type, BigInteger nonce, + BigInteger gasPrice, BigInteger gasLimit, + String to, BigInteger value, String from, byte[] payload, BigInteger feeRatio) { super(chainId, type, nonce, gasPrice, gasLimit, from, to, value); this.payload = payload; this.feeRatio = feeRatio; } - public static TxTypeFeeDelegatedValueTransferMemoWithRatio createTransaction(long chainId, TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload, BigInteger feeRatio) { - return new TxTypeFeeDelegatedValueTransferMemoWithRatio(chainId, type, nonce, gasPrice, gasLimit, to, value, from, payload, feeRatio); + public static TxTypeFeeDelegatedValueTransferMemoWithRatio createTransaction(long chainId, TxType.Type type, + BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, + byte[] payload, BigInteger feeRatio) { + return new TxTypeFeeDelegatedValueTransferMemoWithRatio(chainId, type, nonce, gasPrice, gasLimit, to, value, + from, payload, feeRatio); } + public byte[] getPayload() { return payload; } @@ -54,7 +64,8 @@ public BigInteger getFeeRatio() { } /** - * This method is overridden as FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO type. + * This method is overridden as FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO + * type. * The return value is used for rlp encoding. * * @return Type transaction type @@ -65,7 +76,8 @@ public Type getKaiaType() { } /** - * create RlpType List which contains nonce, gas price, gas limit, to, value, from, payload and feeRatio. + * create RlpType List which contains nonce, gas price, gas limit, to, value, + * from, payload and feeRatio. * List elements can be different depending on transaction type. * * @return List RlpType List @@ -82,13 +94,15 @@ public List rlpValues() { } /** - * decode transaction hash from sender to reconstruct transaction with fee payer signature. + * decode transaction hash from sender to reconstruct transaction with fee payer + * signature. * * @param rawTransaction RLP-encoded signed transaction from sender * @return TxTypeFeeDelegatedValueTransferMemoWithRatio decoded transaction */ public static TxTypeFeeDelegatedValueTransferMemoWithRatio decodeFromRawTransaction(byte[] rawTransaction) { - // TxHashRLP = type + encode([nonce, gasPrice, gas, to, value, from, input, feeRatio, txSignatures, feePayer, feePayerSignatures]) + // TxHashRLP = type + encode([nonce, gasPrice, gas, to, value, from, input, + // feeRatio, txSignatures, feePayer, feePayerSignatures]) try { byte[] rawTransactionExceptType = KaiaTransactionUtils.getRawTransactionNoType(rawTransaction); @@ -103,8 +117,8 @@ public static TxTypeFeeDelegatedValueTransferMemoWithRatio decodeFromRawTransact byte[] payload = ((RlpString) values.get(6)).getBytes(); BigInteger feeRatio = ((RlpString) values.get(7)).asPositiveBigInteger(); TxType.Type type = Type.FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO; - TxTypeFeeDelegatedValueTransferMemoWithRatio tx - = TxTypeFeeDelegatedValueTransferMemoWithRatio.createTransaction(type, nonce, gasPrice, gasLimit, to, value, from, payload, feeRatio); + TxTypeFeeDelegatedValueTransferMemoWithRatio tx = TxTypeFeeDelegatedValueTransferMemoWithRatio + .createTransaction(type, nonce, gasPrice, gasLimit, to, value, from, payload, feeRatio); tx.addSignatureData(values, 8); return tx; } catch (Exception e) { diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedValueTransferWithRatio.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedValueTransferWithRatio.java index 666e1803a..478ea6999 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedValueTransferWithRatio.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeFeeDelegatedValueTransferWithRatio.java @@ -14,38 +14,46 @@ public class TxTypeFeeDelegatedValueTransferWithRatio extends TxTypeFeeDelegate { /** - * Fee ratio of the fee payer. If it is 30, 30% of the fee will be paid by the fee payer. + * Fee ratio of the fee payer. If it is 30, 30% of the fee will be paid by the + * fee payer. * 70% will be paid by the sender. */ private final BigInteger feeRatio; protected TxTypeFeeDelegatedValueTransferWithRatio( - TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, BigInteger feeRatio) { + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, + String from, BigInteger feeRatio) { super(type, nonce, gasPrice, gasLimit, from, to, value); this.feeRatio = feeRatio; } public static TxTypeFeeDelegatedValueTransferWithRatio createTransaction( - TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, BigInteger feeRatio) { + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, + String from, BigInteger feeRatio) { return new TxTypeFeeDelegatedValueTransferWithRatio(type, nonce, gasPrice, gasLimit, to, value, from, feeRatio); } protected TxTypeFeeDelegatedValueTransferWithRatio( - long chainId, TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, BigInteger feeRatio) { + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, + BigInteger value, String from, BigInteger feeRatio) { super(chainId, type, nonce, gasPrice, gasLimit, from, to, value); this.feeRatio = feeRatio; } public static TxTypeFeeDelegatedValueTransferWithRatio createTransaction( - long chainId, TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, BigInteger feeRatio) { - return new TxTypeFeeDelegatedValueTransferWithRatio(chainId, type, nonce, gasPrice, gasLimit, to, value, from, feeRatio); + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, + BigInteger value, String from, BigInteger feeRatio) { + return new TxTypeFeeDelegatedValueTransferWithRatio(chainId, type, nonce, gasPrice, gasLimit, to, value, from, + feeRatio); } + public BigInteger getFeeRatio() { return feeRatio; } /** - * create RlpType List which contains nonce, gas price, gas limit, to, value, from and feeRatio. + * create RlpType List which contains nonce, gas price, gas limit, to, value, + * from and feeRatio. * List elements can be different depending on transaction type. * * @return List RlpType List @@ -72,13 +80,15 @@ public Type getKaiaType() { } /** - * decode transaction hash from sender to reconstruct transaction with fee payer signature. + * decode transaction hash from sender to reconstruct transaction with fee payer + * signature. * * @param rawTransaction RLP-encoded signed transaction from sender * @return TxTypeFeeDelegatedValueTransferWithRatio decoded transaction */ public static TxTypeFeeDelegatedValueTransferWithRatio decodeFromRawTransaction(byte[] rawTransaction) { - // TxHashRLP = type + encode([nonce, gasPrice, gas, to, value, from, feeRatio, txSignatures, feePayer, feePayerSignatures]) + // TxHashRLP = type + encode([nonce, gasPrice, gas, to, value, from, feeRatio, + // txSignatures, feePayer, feePayerSignatures]) try { byte[] rawTransactionExceptType = KaiaTransactionUtils.getRawTransactionNoType(rawTransaction); @@ -92,8 +102,8 @@ public static TxTypeFeeDelegatedValueTransferWithRatio decodeFromRawTransaction( String from = ((RlpString) values.get(5)).asString(); BigInteger feeRatio = ((RlpString) values.get(6)).asPositiveBigInteger(); TxType.Type type = Type.FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO; - TxTypeFeeDelegatedValueTransferWithRatio tx - = TxTypeFeeDelegatedValueTransferWithRatio.createTransaction(type, nonce, gasPrice, gasLimit, to, value, from, feeRatio); + TxTypeFeeDelegatedValueTransferWithRatio tx = TxTypeFeeDelegatedValueTransferWithRatio + .createTransaction(type, nonce, gasPrice, gasLimit, to, value, from, feeRatio); tx.addSignatureData(values, 7); return tx; } catch (Exception e) { diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeSmartContractDeploy.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeSmartContractDeploy.java index ece510f94..2c2887051 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeSmartContractDeploy.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeSmartContractDeploy.java @@ -11,7 +11,7 @@ import org.web3j.utils.KaiaTransactionUtils; import org.web3j.utils.Numeric; -public class TxTypeSmartContractDeploy extends AbstractTxType { +public class TxTypeSmartContractDeploy extends AbstractTxType { /** * code of the newly deployed smart contract @@ -24,7 +24,7 @@ public class TxTypeSmartContractDeploy extends AbstractTxType { private final BigInteger codeFormat; public TxTypeSmartContractDeploy( - TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, BigInteger value, String from, byte[] payload, BigInteger codeFormat) { super(type, nonce, gasPrice, gasLimit, from, "", value); this.payload = payload; @@ -32,13 +32,13 @@ public TxTypeSmartContractDeploy( } public static TxTypeSmartContractDeploy createTransaction( - TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, BigInteger value, String from, byte[] payload, BigInteger codeFormat) { return new TxTypeSmartContractDeploy(type, nonce, gasPrice, gasLimit, value, from, payload, codeFormat); } public TxTypeSmartContractDeploy( - long chainId, TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, BigInteger value, String from, byte[] payload, BigInteger codeFormat) { super(chainId, type, nonce, gasPrice, gasLimit, from, "", value); this.payload = payload; @@ -46,10 +46,12 @@ public TxTypeSmartContractDeploy( } public static TxTypeSmartContractDeploy createTransaction( - long chainId, TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, BigInteger value, String from, byte[] payload, BigInteger codeFormat) { - return new TxTypeSmartContractDeploy(chainId, type, nonce, gasPrice, gasLimit, value, from, payload, codeFormat); + return new TxTypeSmartContractDeploy(chainId, type, nonce, gasPrice, gasLimit, value, from, payload, + codeFormat); } + public byte[] getPayload() { return payload; } @@ -59,7 +61,8 @@ public BigInteger getCodeFormat() { } /** - * create RlpType List which contains nonce, gas price, gas limit, to, value, from, payload and isHumanReadable. + * create RlpType List which contains nonce, gas price, gas limit, to, value, + * from, payload and isHumanReadable. * List elements can be different depending on transaction type. * * @return List RlpType List @@ -88,13 +91,15 @@ public Type getKaiaType() { } /** - * decode transaction hash from sender to reconstruct transaction with fee payer signature. + * decode transaction hash from sender to reconstruct transaction with fee payer + * signature. * * @param rawTransaction RLP-encoded signed transaction from sender * @return TxTypeSmartContractDeploy decoded transaction */ public static TxTypeSmartContractDeploy decodeFromRawTransaction(byte[] rawTransaction) { - // TxHashRLP = type + encode([nonce, gasPrice, gas, to, value, from, input, humanReadable, codeFormat, txSignatures]) + // TxHashRLP = type + encode([nonce, gasPrice, gas, to, value, from, input, + // humanReadable, codeFormat, txSignatures]) try { byte[] rawTransactionExceptType = KaiaTransactionUtils.getRawTransactionNoType(rawTransaction); RlpList rlpList = RlpDecoder.decode(rawTransactionExceptType); @@ -103,15 +108,15 @@ public static TxTypeSmartContractDeploy decodeFromRawTransaction(byte[] rawTrans BigInteger nonce = ((RlpString) values.get(0)).asPositiveBigInteger(); BigInteger gasPrice = ((RlpString) values.get(1)).asPositiveBigInteger(); BigInteger gasLimit = ((RlpString) values.get(2)).asPositiveBigInteger(); - //String to = ((RlpString) values.get(3)).asString(); + // String to = ((RlpString) values.get(3)).asString(); BigInteger value = ((RlpString) values.get(4)).asPositiveBigInteger(); String from = ((RlpString) values.get(5)).asString(); byte[] payload = ((RlpString) values.get(6)).getBytes(); BigInteger codeFormat = ((RlpString) values.get(8)).asPositiveBigInteger(); TxType.Type type = Type.SMART_CONTRACT_DEPLOY; - TxTypeSmartContractDeploy tx - = new TxTypeSmartContractDeploy(type, nonce, gasPrice, gasLimit, value, from, payload, codeFormat); + TxTypeSmartContractDeploy tx = new TxTypeSmartContractDeploy(type, nonce, gasPrice, gasLimit, value, from, + payload, codeFormat); tx.addSignatureData(values, 9); return tx; } catch (Exception e) { diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeSmartContractExecution.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeSmartContractExecution.java index ab880c8e4..0d4b073b2 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeSmartContractExecution.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeSmartContractExecution.java @@ -11,7 +11,7 @@ import org.web3j.utils.KaiaTransactionUtils; import org.web3j.utils.Numeric; -public class TxTypeSmartContractExecution extends AbstractTxType { +public class TxTypeSmartContractExecution extends AbstractTxType { /** * input data of the smart contract @@ -19,36 +19,38 @@ public class TxTypeSmartContractExecution extends AbstractTxType { private final byte[] payload; protected TxTypeSmartContractExecution( - TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload) { - super(type,nonce, gasPrice, gasLimit, from, to, value); + super(type, nonce, gasPrice, gasLimit, from, to, value); this.payload = payload; } public static TxTypeSmartContractExecution createTransaction( - TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload) { - return new TxTypeSmartContractExecution(type,nonce, gasPrice, gasLimit, to, value, from, payload); + return new TxTypeSmartContractExecution(type, nonce, gasPrice, gasLimit, to, value, from, payload); } protected TxTypeSmartContractExecution( - long chainId, TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload) { - super(chainId, type,nonce, gasPrice, gasLimit, from, to, value); + super(chainId, type, nonce, gasPrice, gasLimit, from, to, value); this.payload = payload; } public static TxTypeSmartContractExecution createTransaction( - long chainId, TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload) { - return new TxTypeSmartContractExecution(chainId, type,nonce, gasPrice, gasLimit, to, value, from, payload); + return new TxTypeSmartContractExecution(chainId, type, nonce, gasPrice, gasLimit, to, value, from, payload); } + public byte[] getPayload() { return payload; } /** - * create RlpType List which contains nonce, gas price, gas limit, to, value, from and payload. + * create RlpType List which contains nonce, gas price, gas limit, to, value, + * from and payload. * List elements can be different depending on transaction type. * * @return List RlpType List @@ -75,13 +77,15 @@ public TxType.Type getKaiaType() { } /** - * decode transaction hash from sender to reconstruct transaction with fee payer signature. + * decode transaction hash from sender to reconstruct transaction with fee payer + * signature. * * @param rawTransaction RLP-encoded signed transaction from sender * @return TxTypeSmartContractExecution decoded transaction */ public static TxTypeSmartContractExecution decodeFromRawTransaction(byte[] rawTransaction) { - //TxHashRLP = type + encode([nonce, gasPrice, gas, to, value, from, input, txSignatures]) + // TxHashRLP = type + encode([nonce, gasPrice, gas, to, value, from, input, + // txSignatures]) try { byte[] rawTransactionExceptType = KaiaTransactionUtils.getRawTransactionNoType(rawTransaction); RlpList rlpList = RlpDecoder.decode(rawTransactionExceptType); @@ -96,8 +100,8 @@ public static TxTypeSmartContractExecution decodeFromRawTransaction(byte[] rawTr byte[] payload = ((RlpString) values.get(6)).getBytes(); TxType.Type type = Type.SMART_CONTRACT_EXECUTION; - TxTypeSmartContractExecution tx - = TxTypeSmartContractExecution.createTransaction(type, nonce, gasPrice, gasLimit, to, value, from, payload); + TxTypeSmartContractExecution tx = TxTypeSmartContractExecution.createTransaction(type, nonce, gasPrice, + gasLimit, to, value, from, payload); tx.addSignatureData(values, 7); return tx; } catch (Exception e) { diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeValueTransfer.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeValueTransfer.java index 364b83d6f..8bc86a319 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeValueTransfer.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeValueTransfer.java @@ -13,39 +13,44 @@ /** * Transaction class used for signing 1559 transactions locally.
- * For the specification, refer to p4 of the yellow + * For the specification, refer to p4 of the + * yellow * paper. */ -public class TxTypeValueTransfer extends AbstractTxType { +public class TxTypeValueTransfer extends AbstractTxType { - public TxTypeValueTransfer(TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from) { + public TxTypeValueTransfer(TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, + BigInteger value, String from) { super(type, nonce, gasPrice, gasLimit, from, to, value); } - public TxTypeValueTransfer(long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from) { + public TxTypeValueTransfer(long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, + BigInteger gasLimit, String to, BigInteger value, String from) { super(chainId, type, nonce, gasPrice, gasLimit, from, to, value); } public static TxTypeValueTransfer createTransaction( - TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from) { return new TxTypeValueTransfer(type, nonce, gasPrice, gasLimit, to, value, from); } public static TxTypeValueTransfer createTransaction( - long chainId, TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from) { return new TxTypeValueTransfer(chainId, type, nonce, gasPrice, gasLimit, to, value, from); } /** - * decode transaction hash from sender to reconstruct transaction with fee payer signature. + * decode transaction hash from sender to reconstruct transaction with fee payer + * signature. * * @param rawTransaction RLP-encoded signed transaction from sender * @return TxTypeValueTransfer decoded transaction */ public static TxTypeValueTransfer decodeFromRawTransaction(byte[] rawTransaction) { - // TxHashRLP = type + encode([nonce, gasPrice, gas, to, value, from, txSignatures]) + // TxHashRLP = type + encode([nonce, gasPrice, gas, to, value, from, + // txSignatures]) try { byte[] rawTransactionExceptType = KaiaTransactionUtils.getRawTransactionNoType(rawTransaction); RlpList rlpList = RlpDecoder.decode(rawTransactionExceptType); @@ -58,8 +63,8 @@ public static TxTypeValueTransfer decodeFromRawTransaction(byte[] rawTransaction BigInteger value = ((RlpString) values.get(4)).asPositiveBigInteger(); String from = ((RlpString) values.get(5)).asString(); TxType.Type type = Type.VALUE_TRANSFER; - TxTypeValueTransfer tx - = TxTypeValueTransfer.createTransaction(type, nonce, gasPrice, gasLimit, to, value, from); + TxTypeValueTransfer tx = TxTypeValueTransfer.createTransaction(type, nonce, gasPrice, gasLimit, to, value, + from); tx.addSignatureData(values, 6); return tx; } catch (Exception e) { @@ -85,10 +90,9 @@ public Type getKaiaType() { return Type.VALUE_TRANSFER; } - - /** - * create RlpType List which contains nonce, gas price, gas limit, to, value and from. + * create RlpType List which contains nonce, gas price, gas limit, to, value and + * from. * List elements can be different depending on transaction type. * * @return List RlpType List @@ -102,7 +106,6 @@ public List rlpValues() { return result; } - @Override public List asRlpValues(SignatureData signatureData) { // TODO Auto-generated method stub diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeValueTransferMemo.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeValueTransferMemo.java index 4c0293791..43ab5fdb4 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeValueTransferMemo.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/crypto/transaction/type/TxTypeValueTransferMemo.java @@ -13,43 +13,51 @@ /** * Transaction class used for signing 1559 transactions locally.
- * For the specification, refer to p4 of the yellow + * For the specification, refer to p4 of the + * yellow * paper. */ -public class TxTypeValueTransferMemo extends AbstractTxType { +public class TxTypeValueTransferMemo extends AbstractTxType { /** * memo */ private final byte[] payload; - protected TxTypeValueTransferMemo(TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload) { + protected TxTypeValueTransferMemo(TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, + String to, BigInteger value, String from, byte[] payload) { super(type, nonce, gasPrice, gasLimit, from, to, value); this.payload = payload; } public static TxTypeValueTransferMemo createTransaction( - TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload) { + TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, + String from, byte[] payload) { return new TxTypeValueTransferMemo(type, nonce, gasPrice, gasLimit, to, value, from, payload); } - protected TxTypeValueTransferMemo(long chainId, TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload) { + protected TxTypeValueTransferMemo(long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, + BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload) { super(chainId, type, nonce, gasPrice, gasLimit, from, to, value); this.payload = payload; } public static TxTypeValueTransferMemo createTransaction( - long chainId, TxType.Type type,BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String from, byte[] payload) { + long chainId, TxType.Type type, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, + BigInteger value, String from, byte[] payload) { return new TxTypeValueTransferMemo(chainId, type, nonce, gasPrice, gasLimit, to, value, from, payload); } + /** - * decode transaction hash from sender to reconstruct transaction with fee payer signature. + * decode transaction hash from sender to reconstruct transaction with fee payer + * signature. * * @param rawTransaction RLP-encoded signed transaction from sender * @return TxTypeValueTransferMemo decoded transaction */ public static TxTypeValueTransferMemo decodeFromRawTransaction(byte[] rawTransaction) { - // TxHashRLP = type + encode([nonce, gasPrice, gas, to, value, from, input, txSignatures]) + // TxHashRLP = type + encode([nonce, gasPrice, gas, to, value, from, input, + // txSignatures]) try { byte[] rawTransactionExceptType = KaiaTransactionUtils.getRawTransactionNoType(rawTransaction); RlpList rlpList = RlpDecoder.decode(rawTransactionExceptType); @@ -63,8 +71,8 @@ public static TxTypeValueTransferMemo decodeFromRawTransaction(byte[] rawTransac String from = ((RlpString) values.get(5)).asString(); byte[] payload = ((RlpString) values.get(6)).getBytes(); TxType.Type type = Type.VALUE_TRANSFER_MEMO; - TxTypeValueTransferMemo tx - = TxTypeValueTransferMemo.createTransaction(type, nonce, gasPrice, gasLimit, to, value, from, payload); + TxTypeValueTransferMemo tx = TxTypeValueTransferMemo.createTransaction(type, nonce, gasPrice, gasLimit, to, + value, from, payload); tx.addSignatureData(values, 7); return tx; } catch (Exception e) { @@ -96,7 +104,8 @@ public Type getKaiaType() { } /** - * create RlpType List which contains nonce, gas price, gas limit, to, value, from and payload. + * create RlpType List which contains nonce, gas price, gas limit, to, value, + * from and payload. * List elements can be different depending on transaction type. * * @return List RlpType List diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/SimpleStorage.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/SimpleStorage.java index 057265a68..49d71f264 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/SimpleStorage.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/SimpleStorage.java @@ -17,13 +17,19 @@ import org.web3j.tx.gas.ContractGasProvider; /** - *

Auto generated code. - *

Do not modify! - *

Please use the web3j command line tools, - * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the - * codegen module to update. + *

+ * Auto generated code. + *

+ * Do not modify! + *

+ * Please use the web3j + * command line tools, + * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the + * codegen + * module to update. * - *

Generated with web3j version 1.4.2. + *

+ * Generated with web3j version 1.4.2. */ @SuppressWarnings("rawtypes") public class SimpleStorage extends Contract { @@ -34,71 +40,84 @@ public class SimpleStorage extends Contract { public static final String FUNC_SET = "set"; @Deprecated - protected SimpleStorage(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + protected SimpleStorage(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, + BigInteger gasLimit) { super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); } - protected SimpleStorage(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + protected SimpleStorage(String contractAddress, Web3j web3j, Credentials credentials, + ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, credentials, contractGasProvider); } @Deprecated - protected SimpleStorage(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + protected SimpleStorage(String contractAddress, Web3j web3j, TransactionManager transactionManager, + BigInteger gasPrice, BigInteger gasLimit) { super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); } - protected SimpleStorage(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + protected SimpleStorage(String contractAddress, Web3j web3j, TransactionManager transactionManager, + ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); } public RemoteFunctionCall get() { - final Function function = new Function(FUNC_GET, - Arrays.asList(), - Arrays.>asList(new TypeReference() {})); + final Function function = new Function(FUNC_GET, + Arrays.asList(), + Arrays.>asList(new TypeReference() { + })); return executeRemoteCallSingleValueReturn(function, BigInteger.class); } public RemoteFunctionCall set(BigInteger x) { final Function function = new Function( - FUNC_SET, - Arrays.asList(new org.web3j.abi.datatypes.generated.Uint256(x)), + FUNC_SET, + Arrays.asList(new org.web3j.abi.datatypes.generated.Uint256(x)), Collections.>emptyList()); return executeRemoteCallTransaction(function); } @Deprecated - public static SimpleStorage load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + public static SimpleStorage load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, + BigInteger gasLimit) { return new SimpleStorage(contractAddress, web3j, credentials, gasPrice, gasLimit); } @Deprecated - public static SimpleStorage load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + public static SimpleStorage load(String contractAddress, Web3j web3j, TransactionManager transactionManager, + BigInteger gasPrice, BigInteger gasLimit) { return new SimpleStorage(contractAddress, web3j, transactionManager, gasPrice, gasLimit); } - public static SimpleStorage load(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + public static SimpleStorage load(String contractAddress, Web3j web3j, Credentials credentials, + ContractGasProvider contractGasProvider) { return new SimpleStorage(contractAddress, web3j, credentials, contractGasProvider); } - public static SimpleStorage load(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + public static SimpleStorage load(String contractAddress, Web3j web3j, TransactionManager transactionManager, + ContractGasProvider contractGasProvider) { return new SimpleStorage(contractAddress, web3j, transactionManager, contractGasProvider); } - public static RemoteCall deploy(Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + public static RemoteCall deploy(Web3j web3j, Credentials credentials, + ContractGasProvider contractGasProvider) { return deployRemoteCall(SimpleStorage.class, web3j, credentials, contractGasProvider, BINARY, ""); } @Deprecated - public static RemoteCall deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + public static RemoteCall deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, + BigInteger gasLimit) { return deployRemoteCall(SimpleStorage.class, web3j, credentials, gasPrice, gasLimit, BINARY, ""); } - public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, + ContractGasProvider contractGasProvider) { return deployRemoteCall(SimpleStorage.class, web3j, transactionManager, contractGasProvider, BINARY, ""); } @Deprecated - public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, + BigInteger gasPrice, BigInteger gasLimit) { return deployRemoteCall(SimpleStorage.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, ""); } } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/accountKey/AccountUpdateWithMultiSigExample.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/accountKey/AccountUpdateWithMultiSigExample.java index 8801e8419..d59fefede 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/accountKey/AccountUpdateWithMultiSigExample.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/accountKey/AccountUpdateWithMultiSigExample.java @@ -29,9 +29,12 @@ public class AccountUpdateWithMultiSigExample { public static void run() throws Exception { Web3j web3j = Web3j.build(new HttpService(keySample.BAOBAB_URL)); - KaiaCredentials credential1 = KaiaCredentials.create(keySample.MULTI_KEY_privkey1, keySample.MULTI_KEY_address); - KaiaCredentials credential2 = KaiaCredentials.create(keySample.MULTI_KEY_privkey2, keySample.MULTI_KEY_address); - KaiaCredentials credential3 = KaiaCredentials.create(keySample.MULTI_KEY_privkey3, keySample.MULTI_KEY_address); + KaiaCredentials credential1 = KaiaCredentials.create(keySample.MULTI_KEY_privkey1, + keySample.MULTI_KEY_address); + KaiaCredentials credential2 = KaiaCredentials.create(keySample.MULTI_KEY_privkey2, + keySample.MULTI_KEY_address); + KaiaCredentials credential3 = KaiaCredentials.create(keySample.MULTI_KEY_privkey3, + keySample.MULTI_KEY_address); BigInteger GAS_PRICE = BigInteger.valueOf(50000000000L); BigInteger GAS_LIMIT = BigInteger.valueOf(6721950); diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/accountKey/AccountUpdateWithPubKeyExample.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/accountKey/AccountUpdateWithPubKeyExample.java index bc794f831..8c153d030 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/accountKey/AccountUpdateWithPubKeyExample.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/accountKey/AccountUpdateWithPubKeyExample.java @@ -24,7 +24,8 @@ public class AccountUpdateWithPubKeyExample { public static void run() throws Exception { - KaiaCredentials credentials = KaiaCredentials.create(keySample.PUBLIC_KEY_privkey, keySample.PUBLIC_KEY_address); + KaiaCredentials credentials = KaiaCredentials.create(keySample.PUBLIC_KEY_privkey, + keySample.PUBLIC_KEY_address); Web3j web3j = Web3j.build(new HttpService(keySample.BAOBAB_URL)); BigInteger GAS_PRICE = BigInteger.valueOf(50000000000L); diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/accountKey/AccountUpdateWithRoleBasedExample.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/accountKey/AccountUpdateWithRoleBasedExample.java index 2a88ff97a..9d0b8d164 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/accountKey/AccountUpdateWithRoleBasedExample.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/accountKey/AccountUpdateWithRoleBasedExample.java @@ -31,9 +31,12 @@ public class AccountUpdateWithRoleBasedExample { public static void run() throws Exception { Web3j web3j = Web3j.build(new HttpService(keySample.BAOBAB_URL)); - KaiaCredentials credential1 = KaiaCredentials.create(keySample.ROLEBASED_KEY_transactionkey, keySample.ROLEBASED_KEY_address); - KaiaCredentials credential2 = KaiaCredentials.create(keySample.ROLEBASED_KEY_updatekey, keySample.ROLEBASED_KEY_address); - KaiaCredentials credential3 = KaiaCredentials.create(keySample.ROLEBASED_KEY_feepayer, keySample.ROLEBASED_KEY_address); + KaiaCredentials credential1 = KaiaCredentials.create(keySample.ROLEBASED_KEY_transactionkey, + keySample.ROLEBASED_KEY_address); + KaiaCredentials credential2 = KaiaCredentials.create(keySample.ROLEBASED_KEY_updatekey, + keySample.ROLEBASED_KEY_address); + KaiaCredentials credential3 = KaiaCredentials.create(keySample.ROLEBASED_KEY_feepayer, + keySample.ROLEBASED_KEY_address); BigInteger GAS_PRICE = BigInteger.valueOf(50000000000L); BigInteger GAS_LIMIT = BigInteger.valueOf(6721950); diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/contracts/Counter.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/contracts/Counter.java index 3a3432f98..e5e7bb5bd 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/contracts/Counter.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/contracts/Counter.java @@ -27,13 +27,19 @@ import org.web3j.tx.gas.ContractGasProvider; /** - *

Auto generated code. - *

Do not modify! - *

Please use the web3j command line tools, - * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the - * codegen module to update. + *

+ * Auto generated code. + *

+ * Do not modify! + *

+ * Please use the web3j + * command line tools, + * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the + * codegen + * module to update. * - *

Generated with web3j version 1.4.2. + *

+ * Generated with web3j version 1.4.2. */ @SuppressWarnings("rawtypes") public class Counter extends Contract { @@ -45,30 +51,35 @@ public class Counter extends Contract { public static final String FUNC_SETNUMBER = "setNumber"; - public static final Event SETNUMBER_EVENT = new Event("SetNumber", - Arrays.>asList(new TypeReference() {})); - ; + public static final Event SETNUMBER_EVENT = new Event("SetNumber", + Arrays.>asList(new TypeReference() { + }));; @Deprecated - protected Counter(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + protected Counter(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, + BigInteger gasLimit) { super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); } - protected Counter(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + protected Counter(String contractAddress, Web3j web3j, Credentials credentials, + ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, credentials, contractGasProvider); } @Deprecated - protected Counter(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + protected Counter(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, + BigInteger gasLimit) { super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); } - protected Counter(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + protected Counter(String contractAddress, Web3j web3j, TransactionManager transactionManager, + ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); } public static List getSetNumberEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(SETNUMBER_EVENT, transactionReceipt); + List valueList = staticExtractEventParametersWithLog(SETNUMBER_EVENT, + transactionReceipt); ArrayList responses = new ArrayList(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { SetNumberEventResponse typedResponse = new SetNumberEventResponse(); @@ -92,7 +103,8 @@ public SetNumberEventResponse apply(Log log) { }); } - public Flowable setNumberEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + public Flowable setNumberEventFlowable(DefaultBlockParameter startBlock, + DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); filter.addSingleTopic(EventEncoder.encode(SETNUMBER_EVENT)); return setNumberEventFlowable(filter); @@ -100,65 +112,80 @@ public Flowable setNumberEventFlowable(DefaultBlockParam public RemoteFunctionCall increment() { final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( - FUNC_INCREMENT, - Arrays.asList(), + FUNC_INCREMENT, + Arrays.asList(), Collections.>emptyList()); return executeRemoteCallTransaction(function); } public RemoteFunctionCall number() { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_NUMBER, - Arrays.asList(), - Arrays.>asList(new TypeReference() {})); + final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_NUMBER, + Arrays.asList(), + Arrays.>asList(new TypeReference() { + })); return executeRemoteCallSingleValueReturn(function, BigInteger.class); } public RemoteFunctionCall setNumber(BigInteger newNumber) { final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( - FUNC_SETNUMBER, - Arrays.asList(new org.web3j.abi.datatypes.generated.Uint256(newNumber)), + FUNC_SETNUMBER, + Arrays.asList(new org.web3j.abi.datatypes.generated.Uint256(newNumber)), Collections.>emptyList()); return executeRemoteCallTransaction(function); } @Deprecated - public static Counter load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + public static Counter load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, + BigInteger gasLimit) { return new Counter(contractAddress, web3j, credentials, gasPrice, gasLimit); } @Deprecated - public static Counter load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + public static Counter load(String contractAddress, Web3j web3j, TransactionManager transactionManager, + BigInteger gasPrice, BigInteger gasLimit) { return new Counter(contractAddress, web3j, transactionManager, gasPrice, gasLimit); } - public static Counter load(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + public static Counter load(String contractAddress, Web3j web3j, Credentials credentials, + ContractGasProvider contractGasProvider) { return new Counter(contractAddress, web3j, credentials, contractGasProvider); } - public static Counter load(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + public static Counter load(String contractAddress, Web3j web3j, TransactionManager transactionManager, + ContractGasProvider contractGasProvider) { return new Counter(contractAddress, web3j, transactionManager, contractGasProvider); } - public static RemoteCall deploy(Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider, BigInteger initNumber) { - String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.asList(new org.web3j.abi.datatypes.generated.Uint256(initNumber))); + public static RemoteCall deploy(Web3j web3j, Credentials credentials, + ContractGasProvider contractGasProvider, BigInteger initNumber) { + String encodedConstructor = FunctionEncoder + .encodeConstructor(Arrays.asList(new org.web3j.abi.datatypes.generated.Uint256(initNumber))); return deployRemoteCall(Counter.class, web3j, credentials, contractGasProvider, BINARY, encodedConstructor); } - public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider, BigInteger initNumber) { - String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.asList(new org.web3j.abi.datatypes.generated.Uint256(initNumber))); - return deployRemoteCall(Counter.class, web3j, transactionManager, contractGasProvider, BINARY, encodedConstructor); + public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, + ContractGasProvider contractGasProvider, BigInteger initNumber) { + String encodedConstructor = FunctionEncoder + .encodeConstructor(Arrays.asList(new org.web3j.abi.datatypes.generated.Uint256(initNumber))); + return deployRemoteCall(Counter.class, web3j, transactionManager, contractGasProvider, BINARY, + encodedConstructor); } @Deprecated - public static RemoteCall deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, BigInteger initNumber) { - String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.asList(new org.web3j.abi.datatypes.generated.Uint256(initNumber))); + public static RemoteCall deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, + BigInteger gasLimit, BigInteger initNumber) { + String encodedConstructor = FunctionEncoder + .encodeConstructor(Arrays.asList(new org.web3j.abi.datatypes.generated.Uint256(initNumber))); return deployRemoteCall(Counter.class, web3j, credentials, gasPrice, gasLimit, BINARY, encodedConstructor); } @Deprecated - public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, BigInteger initNumber) { - String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.asList(new org.web3j.abi.datatypes.generated.Uint256(initNumber))); - return deployRemoteCall(Counter.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, encodedConstructor); + public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, + BigInteger gasLimit, BigInteger initNumber) { + String encodedConstructor = FunctionEncoder + .encodeConstructor(Arrays.asList(new org.web3j.abi.datatypes.generated.Uint256(initNumber))); + return deployRemoteCall(Counter.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, + encodedConstructor); } public static class SetNumberEventResponse extends BaseEventResponse { diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/AccountUpdateExample.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/AccountUpdateExample.java index 57d63429a..905d265a9 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/AccountUpdateExample.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/AccountUpdateExample.java @@ -24,59 +24,59 @@ * */ public class AccountUpdateExample implements keySample { - /** - * - */ + /** + * + */ - public static void run(KaiaCredentials credentials) throws Exception { + public static void run() throws Exception { - Web3j web3j = Web3j.build(new HttpService(keySample.BAOBAB_URL)); - KaiaCredentials new_credentials = KaiaCredentials.create(PUBLIC_KEY_privkey, PUBLIC_KEY_address); + Web3j web3j = Web3j.build(new HttpService(keySample.BAOBAB_URL)); + KaiaCredentials credentials = KaiaCredentials.create(PUBLIC_KEY_privkey, PUBLIC_KEY_address); - BigInteger GAS_PRICE = BigInteger.valueOf(50000000000L); - BigInteger GAS_LIMIT = BigInteger.valueOf(6721950); - String from = credentials.getAddress(); - EthChainId EthchainId = web3j.ethChainId().send(); - long chainId = EthchainId.getChainId().longValue(); - BigInteger nonce = web3j.ethGetTransactionCount(from, DefaultBlockParameterName.LATEST).send() - .getTransactionCount(); + BigInteger GAS_PRICE = BigInteger.valueOf(50000000000L); + BigInteger GAS_LIMIT = BigInteger.valueOf(6721950); + String from = credentials.getAddress(); + EthChainId EthchainId = web3j.ethChainId().send(); + long chainId = EthchainId.getChainId().longValue(); + BigInteger nonce = web3j.ethGetTransactionCount(from, DefaultBlockParameterName.LATEST).send() + .getTransactionCount(); - BigInteger newPubkey = new_credentials.getEcKeyPair().getPublicKey(); + BigInteger newPubkey = credentials.getEcKeyPair().getPublicKey(); - AccountKeyPublic accountkey = AccountKeyPublic.create(newPubkey); + AccountKeyPublic accountkey = AccountKeyPublic.create(newPubkey); - TxType.Type type = Type.ACCOUNT_UPDATE; + TxType.Type type = Type.ACCOUNT_UPDATE; - KaiaRawTransaction raw = KaiaRawTransaction.createTransaction( - type, - nonce, - GAS_PRICE, - GAS_LIMIT, - from, - accountkey); + KaiaRawTransaction raw = KaiaRawTransaction.createTransaction( + type, + nonce, + GAS_PRICE, + GAS_LIMIT, + from, + accountkey); - byte[] signedMessage = KaiaTransactionEncoder.signMessage(raw, chainId, credentials); - String hexValue = Numeric.toHexString(signedMessage); - EthSendTransaction transactionResponse = web3j.ethSendRawTransaction(hexValue).send(); - System.out.println("TxHash : \n " + transactionResponse.getResult()); - String txHash = transactionResponse.getResult(); + byte[] signedMessage = KaiaTransactionEncoder.signMessage(raw, chainId, credentials); + String hexValue = Numeric.toHexString(signedMessage); + EthSendTransaction transactionResponse = web3j.ethSendRawTransaction(hexValue).send(); + System.out.println("TxHash : \n " + transactionResponse.getResult()); + String txHash = transactionResponse.getResult(); - int DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH = 40; - int DEFAULT_BLOCK_TIME = 1 * 1000; - long DEFAULT_POLLING_FREQUENCY = DEFAULT_BLOCK_TIME; - TransactionReceiptProcessor transactionReceiptProcessor = new PollingTransactionReceiptProcessor(web3j, - DEFAULT_POLLING_FREQUENCY, DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH); - org.web3j.protocol.core.methods.response.TransactionReceipt ethReceipt = transactionReceiptProcessor - .waitForTransactionReceipt(txHash); - System.out.println("Receipt from eth_getTransactionReceipt : \n" + ethReceipt); - TransactionReceipt receipt = web3j.kaiaGetTransactionReceipt(txHash).send().getResult(); - System.out.println("Receipt from kaia_getTransactionReceipt : \n" + receipt); - web3j.shutdown(); + int DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH = 40; + int DEFAULT_BLOCK_TIME = 1 * 1000; + long DEFAULT_POLLING_FREQUENCY = DEFAULT_BLOCK_TIME; + TransactionReceiptProcessor transactionReceiptProcessor = new PollingTransactionReceiptProcessor(web3j, + DEFAULT_POLLING_FREQUENCY, DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH); + org.web3j.protocol.core.methods.response.TransactionReceipt ethReceipt = transactionReceiptProcessor + .waitForTransactionReceipt(txHash); + System.out.println("Receipt from eth_getTransactionReceipt : \n" + ethReceipt); + TransactionReceipt receipt = web3j.kaiaGetTransactionReceipt(txHash).send().getResult(); + System.out.println("Receipt from kaia_getTransactionReceipt : \n" + receipt); + web3j.shutdown(); - TxTypeAccountUpdate rawTransaction = TxTypeAccountUpdate.decodeFromRawTransaction(signedMessage); + TxTypeAccountUpdate rawTransaction = TxTypeAccountUpdate.decodeFromRawTransaction(signedMessage); - System.out.println("TxType : " + rawTransaction.getKaiaType()); + System.out.println("TxType : " + rawTransaction.getKaiaType()); - } + } } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedAccountUpdateExample.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedAccountUpdateExample.java index 565fda529..e6592c40c 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedAccountUpdateExample.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedAccountUpdateExample.java @@ -25,10 +25,10 @@ */ public class FeeDelegatedAccountUpdateExample implements keySample { - public static void run(KaiaCredentials credentials) throws Exception { + public static void run() throws Exception { Web3j web3j = Web3j.build(new HttpService(keySample.BAOBAB_URL)); - KaiaCredentials new_credentials = KaiaCredentials.create(PUBLIC_KEY_privkey, PUBLIC_KEY_address); + KaiaCredentials credentials = KaiaCredentials.create(PUBLIC_KEY_privkey, PUBLIC_KEY_address); KaiaCredentials credentials_feepayer = KaiaCredentials.create(keySample.LEGACY_KEY_FEEPAYER_privkey); BigInteger GAS_PRICE = BigInteger.valueOf(50000000000L); BigInteger GAS_LIMIT = BigInteger.valueOf(6721950); @@ -38,7 +38,7 @@ public static void run(KaiaCredentials credentials) throws Exception { BigInteger nonce = web3j.ethGetTransactionCount(from, DefaultBlockParameterName.LATEST).send() .getTransactionCount(); - BigInteger newPubkey = new_credentials.getEcKeyPair().getPublicKey(); + BigInteger newPubkey = credentials.getEcKeyPair().getPublicKey(); AccountKeyPublic accountkey = AccountKeyPublic.create(newPubkey); diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedAccountUpdateWithRatioExample.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedAccountUpdateWithRatioExample.java index cb8f34dff..78130e3f4 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedAccountUpdateWithRatioExample.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedAccountUpdateWithRatioExample.java @@ -8,6 +8,7 @@ import org.web3j.crypto.transaction.account.AccountKeyPublic; import org.web3j.crypto.transaction.type.TxType; import org.web3j.crypto.transaction.type.TxTypeFeeDelegatedAccountUpdate; +import org.web3j.crypto.transaction.type.TxTypeFeeDelegatedAccountUpdateWithRatio; import org.web3j.crypto.transaction.type.TxType.Type; import org.web3j.tx.response.PollingTransactionReceiptProcessor; import org.web3j.tx.response.TransactionReceiptProcessor; @@ -25,10 +26,10 @@ */ public class FeeDelegatedAccountUpdateWithRatioExample implements keySample { - public static void run(KaiaCredentials credentials) throws Exception { + public static void run() throws Exception { Web3j web3j = Web3j.build(new HttpService(keySample.BAOBAB_URL)); - KaiaCredentials new_credentials = KaiaCredentials.create(PUBLIC_KEY_privkey, PUBLIC_KEY_address); + KaiaCredentials credentials = KaiaCredentials.create(PUBLIC_KEY_privkey, PUBLIC_KEY_address); KaiaCredentials credentials_feepayer = KaiaCredentials.create(keySample.LEGACY_KEY_FEEPAYER_privkey); BigInteger GAS_PRICE = BigInteger.valueOf(50000000000L); BigInteger GAS_LIMIT = BigInteger.valueOf(6721950); @@ -38,7 +39,7 @@ public static void run(KaiaCredentials credentials) throws Exception { BigInteger nonce = web3j.ethGetTransactionCount(from, DefaultBlockParameterName.LATEST).send() .getTransactionCount(); BigInteger feeRatio = BigInteger.valueOf(30); - BigInteger newPubkey = new_credentials.getEcKeyPair().getPublicKey(); + BigInteger newPubkey = credentials.getEcKeyPair().getPublicKey(); AccountKeyPublic accountkey = AccountKeyPublic.create(newPubkey); @@ -75,7 +76,7 @@ public static void run(KaiaCredentials credentials) throws Exception { System.out.println("Receipt from kaia_getTransactionReceipt : \n" + receipt); web3j.shutdown(); - TxTypeFeeDelegatedAccountUpdate rawTransaction = TxTypeFeeDelegatedAccountUpdate + TxTypeFeeDelegatedAccountUpdateWithRatio rawTransaction = TxTypeFeeDelegatedAccountUpdateWithRatio .decodeFromRawTransaction(signedMessage); System.out.println("TxType : " + rawTransaction.getKaiaType()); diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedCancelExample.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedCancelExample.java index c4fcf97a9..441a35e10 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedCancelExample.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedCancelExample.java @@ -23,59 +23,60 @@ * */ public class FeeDelegatedCancelExample implements keySample { - /** - * - */ + /** + * + */ - public static void run() throws Exception { + public static void run() throws Exception { - Web3j web3j = Web3j.build(new HttpService(keySample.BAOBAB_URL)); - KaiaCredentials credentials = KaiaCredentials.create(keySample.LEGACY_KEY_privkey); - KaiaCredentials credentials_feepayer = KaiaCredentials.create(keySample.LEGACY_KEY_FEEPAYER_privkey); + Web3j web3j = Web3j.build(new HttpService(keySample.BAOBAB_URL)); + KaiaCredentials credentials = KaiaCredentials.create(keySample.LEGACY_KEY_privkey); + KaiaCredentials credentials_feepayer = KaiaCredentials.create(keySample.LEGACY_KEY_FEEPAYER_privkey); - BigInteger GAS_PRICE = BigInteger.valueOf(50000000000L); - BigInteger GAS_LIMIT = BigInteger.valueOf(6721950); - String from = credentials.getAddress(); - EthChainId EthchainId = web3j.ethChainId().send(); - long chainId = EthchainId.getChainId().longValue(); - BigInteger nonce = web3j.ethGetTransactionCount(from, DefaultBlockParameterName.LATEST).send() - .getTransactionCount(); + BigInteger GAS_PRICE = BigInteger.valueOf(50000000000L); + BigInteger GAS_LIMIT = BigInteger.valueOf(6721950); + String from = credentials.getAddress(); + EthChainId EthchainId = web3j.ethChainId().send(); + long chainId = EthchainId.getChainId().longValue(); + BigInteger nonce = web3j.ethGetTransactionCount(from, DefaultBlockParameterName.LATEST).send() + .getTransactionCount(); - TxType.Type type = Type.FEE_DELEGATED_CANCEL; + TxType.Type type = Type.FEE_DELEGATED_CANCEL; - KaiaRawTransaction raw = KaiaRawTransaction.createTransaction( - type, - nonce, - GAS_PRICE, - GAS_LIMIT, - from); + KaiaRawTransaction raw = KaiaRawTransaction.createTransaction( + type, + nonce, + GAS_PRICE, + GAS_LIMIT, + from); - // Sign as sender - byte[] signedMessage = KaiaTransactionEncoder.signMessage(raw, chainId, credentials); + // Sign as sender + byte[] signedMessage = KaiaTransactionEncoder.signMessage(raw, chainId, credentials); - // Sign same message as Fee payer - signedMessage = KaiaTransactionEncoder.signMessageAsFeePayer(raw, chainId, credentials_feepayer); + // Sign same message as Fee payer + signedMessage = KaiaTransactionEncoder.signMessageAsFeePayer(raw, chainId, credentials_feepayer); - String hexValue = Numeric.toHexString(signedMessage); - EthSendTransaction transactionResponse = web3j.ethSendRawTransaction(hexValue).send(); - System.out.println("TxHash : \n " + transactionResponse.getResult()); - String txHash = transactionResponse.getResult(); + String hexValue = Numeric.toHexString(signedMessage); + EthSendTransaction transactionResponse = web3j.ethSendRawTransaction(hexValue).send(); + System.out.println("TxHash : \n " + transactionResponse.getResult()); + String txHash = transactionResponse.getResult(); - int DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH = 40; - int DEFAULT_BLOCK_TIME = 1 * 1000; - long DEFAULT_POLLING_FREQUENCY = DEFAULT_BLOCK_TIME; - TransactionReceiptProcessor transactionReceiptProcessor = new PollingTransactionReceiptProcessor(web3j, - DEFAULT_POLLING_FREQUENCY, DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH); - org.web3j.protocol.core.methods.response.TransactionReceipt ethReceipt = transactionReceiptProcessor - .waitForTransactionReceipt(txHash); - System.out.println("Receipt from eth_getTransactionReceipt : \n" + ethReceipt); - TransactionReceipt receipt = web3j.kaiaGetTransactionReceipt(txHash).send().getResult(); - System.out.println("Receipt from kaia_getTransactionReceipt : \n" + receipt); - web3j.shutdown(); + int DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH = 40; + int DEFAULT_BLOCK_TIME = 1 * 1000; + long DEFAULT_POLLING_FREQUENCY = DEFAULT_BLOCK_TIME; + TransactionReceiptProcessor transactionReceiptProcessor = new PollingTransactionReceiptProcessor(web3j, + DEFAULT_POLLING_FREQUENCY, DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH); + org.web3j.protocol.core.methods.response.TransactionReceipt ethReceipt = transactionReceiptProcessor + .waitForTransactionReceipt(txHash); + System.out.println("Receipt from eth_getTransactionReceipt : \n" + ethReceipt); + TransactionReceipt receipt = web3j.kaiaGetTransactionReceipt(txHash).send().getResult(); + System.out.println("Receipt from kaia_getTransactionReceipt : \n" + receipt); + web3j.shutdown(); - TxTypeFeeDelegatedCancel rawTransaction = TxTypeFeeDelegatedCancel.decodeFromRawTransaction(signedMessage); + TxTypeFeeDelegatedCancel rawTransaction = TxTypeFeeDelegatedCancel + .decodeFromRawTransaction(signedMessage); - System.out.println("TxType : " + rawTransaction.getKaiaType()); - } + System.out.println("TxType : " + rawTransaction.getKaiaType()); + } } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedSmartContractDeployExample.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedSmartContractDeployExample.java index d38d91ef7..cc9bc4f6f 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedSmartContractDeployExample.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedSmartContractDeployExample.java @@ -23,67 +23,68 @@ * */ public class FeeDelegatedSmartContractDeployExample implements keySample { - /** - * - */ - public static void run() throws Exception { + /** + * + */ + public static void run() throws Exception { - Web3j web3j = Web3j.build(new HttpService(keySample.BAOBAB_URL)); - KaiaCredentials credentials = KaiaCredentials.create(keySample.LEGACY_KEY_privkey); - KaiaCredentials credentials_feepayer = KaiaCredentials.create(keySample.LEGACY_KEY_FEEPAYER_privkey); + Web3j web3j = Web3j.build(new HttpService(keySample.BAOBAB_URL)); + KaiaCredentials credentials = KaiaCredentials.create(keySample.LEGACY_KEY_privkey); + KaiaCredentials credentials_feepayer = KaiaCredentials.create(keySample.LEGACY_KEY_FEEPAYER_privkey); - BigInteger GAS_PRICE = BigInteger.valueOf(50000000000L); - BigInteger GAS_LIMIT = BigInteger.valueOf(6721950); - String from = credentials.getAddress(); - BigInteger nonce = web3j.ethGetTransactionCount(from, DefaultBlockParameterName.LATEST).send() - .getTransactionCount(); - String data = "0x60c0604052600c60809081526b48656c6c6f20576f726c642160a01b60a05260009061002b90826100dd565b5034801561003857600080fd5b5061019c565b634e487b7160e01b600052604160045260246000fd5b600181811c9082168061006857607f821691505b60208210810361008857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156100d857600081815260208120601f850160051c810160208610156100b55750805b601f850160051c820191505b818110156100d4578281556001016100c1565b5050505b505050565b81516001600160401b038111156100f6576100f661003e565b61010a816101048454610054565b8461008e565b602080601f83116001811461013f57600084156101275750858301515b600019600386901b1c1916600185901b1785556100d4565b600085815260208120601f198616915b8281101561016e5788860151825594840194600190910190840161014f565b508582101561018c5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b61019a806101ab6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063cfae321714610030575b600080fd5b61003861004e565b60405161004591906100dc565b60405180910390f35b6000805461005b9061012a565b80601f01602080910402602001604051908101604052809291908181526020018280546100879061012a565b80156100d45780601f106100a9576101008083540402835291602001916100d4565b820191906000526020600020905b8154815290600101906020018083116100b757829003601f168201915b505050505081565b600060208083528351808285015260005b81811015610109578581018301518582016040015282016100ed565b506000604082860101526040601f19601f8301168501019250505092915050565b600181811c9082168061013e57607f821691505b60208210810361015e57634e487b7160e01b600052602260045260246000fd5b5091905056fea264697066735822122002272dad43feb87cde6d15be86d8d1af21672f2443deb524dce07ca0210d1cec64736f6c63430008120033"; - EthChainId EthchainId = web3j.ethChainId().send(); - long chainId = EthchainId.getChainId().longValue(); - String to = null; - byte[] payload = Numeric.hexStringToByteArray(data); + BigInteger GAS_PRICE = BigInteger.valueOf(50000000000L); + BigInteger GAS_LIMIT = BigInteger.valueOf(6721950); + String from = credentials.getAddress(); + BigInteger nonce = web3j.ethGetTransactionCount(from, DefaultBlockParameterName.LATEST).send() + .getTransactionCount(); + String data = "0x60c0604052600c60809081526b48656c6c6f20576f726c642160a01b60a05260009061002b90826100dd565b5034801561003857600080fd5b5061019c565b634e487b7160e01b600052604160045260246000fd5b600181811c9082168061006857607f821691505b60208210810361008857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156100d857600081815260208120601f850160051c810160208610156100b55750805b601f850160051c820191505b818110156100d4578281556001016100c1565b5050505b505050565b81516001600160401b038111156100f6576100f661003e565b61010a816101048454610054565b8461008e565b602080601f83116001811461013f57600084156101275750858301515b600019600386901b1c1916600185901b1785556100d4565b600085815260208120601f198616915b8281101561016e5788860151825594840194600190910190840161014f565b508582101561018c5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b61019a806101ab6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063cfae321714610030575b600080fd5b61003861004e565b60405161004591906100dc565b60405180910390f35b6000805461005b9061012a565b80601f01602080910402602001604051908101604052809291908181526020018280546100879061012a565b80156100d45780601f106100a9576101008083540402835291602001916100d4565b820191906000526020600020905b8154815290600101906020018083116100b757829003601f168201915b505050505081565b600060208083528351808285015260005b81811015610109578581018301518582016040015282016100ed565b506000604082860101526040601f19601f8301168501019250505092915050565b600181811c9082168061013e57607f821691505b60208210810361015e57634e487b7160e01b600052602260045260246000fd5b5091905056fea264697066735822122002272dad43feb87cde6d15be86d8d1af21672f2443deb524dce07ca0210d1cec64736f6c63430008120033"; + EthChainId EthchainId = web3j.ethChainId().send(); + long chainId = EthchainId.getChainId().longValue(); + String to = null; + byte[] payload = Numeric.hexStringToByteArray(data); - BigInteger value = BigInteger.ZERO; - BigInteger codeFormat = BigInteger.ZERO; + BigInteger value = BigInteger.ZERO; + BigInteger codeFormat = BigInteger.ZERO; - TxType.Type type = Type.FEE_DELEGATED_SMART_CONTRACT_DEPLOY; + TxType.Type type = Type.FEE_DELEGATED_SMART_CONTRACT_DEPLOY; - KaiaRawTransaction raw = KaiaRawTransaction.createTransaction( - type, - nonce, - GAS_PRICE, - GAS_LIMIT, - to, - value, - from, - payload, - codeFormat); + KaiaRawTransaction raw = KaiaRawTransaction.createTransaction( + type, + nonce, + GAS_PRICE, + GAS_LIMIT, + to, + value, + from, + payload, + codeFormat); - // Sign as sender - byte[] signedMessage = KaiaTransactionEncoder.signMessage(raw, chainId, credentials); + // Sign as sender + byte[] signedMessage = KaiaTransactionEncoder.signMessage(raw, chainId, credentials); - // Sign same message as Fee payer - signedMessage = KaiaTransactionEncoder.signMessageAsFeePayer(raw, chainId, credentials_feepayer); + // Sign same message as Fee payer + signedMessage = KaiaTransactionEncoder.signMessageAsFeePayer(raw, chainId, credentials_feepayer); - String hexValue = Numeric.toHexString(signedMessage); - EthSendTransaction transactionResponse = web3j.ethSendRawTransaction(hexValue).send(); - System.out.println("TxHash : \n " + transactionResponse.getResult()); - String txHash = transactionResponse.getResult(); + String hexValue = Numeric.toHexString(signedMessage); + EthSendTransaction transactionResponse = web3j.ethSendRawTransaction(hexValue).send(); + System.out.println("TxHash : \n " + transactionResponse.getResult()); + String txHash = transactionResponse.getResult(); - int DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH = 40; - int DEFAULT_BLOCK_TIME = 1 * 1000; - long DEFAULT_POLLING_FREQUENCY = DEFAULT_BLOCK_TIME; - TransactionReceiptProcessor transactionReceiptProcessor = new PollingTransactionReceiptProcessor(web3j, - DEFAULT_POLLING_FREQUENCY, DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH); - org.web3j.protocol.core.methods.response.TransactionReceipt ethReceipt = transactionReceiptProcessor - .waitForTransactionReceipt(txHash); - System.out.println("Receipt from eth_getTransactionReceipt : \n" + ethReceipt); - TransactionReceipt receipt = web3j.kaiaGetTransactionReceipt(txHash).send().getResult(); - System.out.println("Receipt from kaia_getTransactionReceipt : \n" + receipt); - web3j.shutdown(); + int DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH = 40; + int DEFAULT_BLOCK_TIME = 1 * 1000; + long DEFAULT_POLLING_FREQUENCY = DEFAULT_BLOCK_TIME; + TransactionReceiptProcessor transactionReceiptProcessor = new PollingTransactionReceiptProcessor(web3j, + DEFAULT_POLLING_FREQUENCY, DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH); + org.web3j.protocol.core.methods.response.TransactionReceipt ethReceipt = transactionReceiptProcessor + .waitForTransactionReceipt(txHash); + System.out.println("Receipt from eth_getTransactionReceipt : \n" + ethReceipt); + TransactionReceipt receipt = web3j.kaiaGetTransactionReceipt(txHash).send().getResult(); + System.out.println("Receipt from kaia_getTransactionReceipt : \n" + receipt); + web3j.shutdown(); - TxTypeSmartContractDeploy rawTransaction = TxTypeSmartContractDeploy.decodeFromRawTransaction(signedMessage); - System.out.println("TxType : " + rawTransaction.getKaiaType()); - } + TxTypeSmartContractDeploy rawTransaction = TxTypeSmartContractDeploy + .decodeFromRawTransaction(signedMessage); + System.out.println("TxType : " + rawTransaction.getKaiaType()); + } } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedSmartContractDeployWithRatioExample.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedSmartContractDeployWithRatioExample.java index 7d8cf4b3b..b5f3b04d0 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedSmartContractDeployWithRatioExample.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedSmartContractDeployWithRatioExample.java @@ -26,7 +26,7 @@ public class FeeDelegatedSmartContractDeployWithRatioExample implements keySampl /** * */ - public void run() throws Exception { + public static void run() throws Exception { Web3j web3j = Web3j.build(new HttpService(keySample.BAOBAB_URL)); KaiaCredentials credentials = KaiaCredentials.create(keySample.LEGACY_KEY_privkey); diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedValueTransferExample.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedValueTransferExample.java index 1bc3ff235..37a088606 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedValueTransferExample.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedValueTransferExample.java @@ -22,57 +22,57 @@ public class FeeDelegatedValueTransferExample implements keySample { - public static void run() throws Exception { - Web3j web3j = Web3j.build(new HttpService(keySample.BAOBAB_URL)); - KaiaCredentials credentials = KaiaCredentials.create(keySample.LEGACY_KEY_privkey); - KaiaCredentials credentials_feepayer = KaiaCredentials.create(keySample.LEGACY_KEY_FEEPAYER_privkey); + public static void run() throws Exception { + Web3j web3j = Web3j.build(new HttpService(keySample.BAOBAB_URL)); + KaiaCredentials credentials = KaiaCredentials.create(keySample.LEGACY_KEY_privkey); + KaiaCredentials credentials_feepayer = KaiaCredentials.create(keySample.LEGACY_KEY_FEEPAYER_privkey); - BigInteger GAS_PRICE = BigInteger.valueOf(50000000000L); - BigInteger GAS_LIMIT = BigInteger.valueOf(6721950); - String from = credentials.getAddress(); - EthChainId EthchainId = web3j.ethChainId().send(); - long chainId = EthchainId.getChainId().longValue(); - String to = "0x000000000000000000000000000000000000dead"; - BigInteger nonce = web3j.ethGetTransactionCount(from, DefaultBlockParameterName.LATEST).send() - .getTransactionCount(); - BigInteger value = BigInteger.valueOf(100); + BigInteger GAS_PRICE = BigInteger.valueOf(50000000000L); + BigInteger GAS_LIMIT = BigInteger.valueOf(6721950); + String from = credentials.getAddress(); + EthChainId EthchainId = web3j.ethChainId().send(); + long chainId = EthchainId.getChainId().longValue(); + String to = "0x000000000000000000000000000000000000dead"; + BigInteger nonce = web3j.ethGetTransactionCount(from, DefaultBlockParameterName.LATEST).send() + .getTransactionCount(); + BigInteger value = BigInteger.valueOf(100); - TxType.Type type = Type.FEE_DELEGATED_VALUE_TRANSFER; + TxType.Type type = Type.FEE_DELEGATED_VALUE_TRANSFER; - KaiaRawTransaction raw = KaiaRawTransaction.createTransaction( - type, - nonce, - GAS_PRICE, - GAS_LIMIT, - to, - value, - from); + KaiaRawTransaction raw = KaiaRawTransaction.createTransaction( + type, + nonce, + GAS_PRICE, + GAS_LIMIT, + to, + value, + from); - // Sign as sender - byte[] signedMessage = KaiaTransactionEncoder.signMessage(raw, chainId, credentials); + // Sign as sender + byte[] signedMessage = KaiaTransactionEncoder.signMessage(raw, chainId, credentials); - // Sign same message as Fee payer - signedMessage = KaiaTransactionEncoder.signMessageAsFeePayer(raw, chainId, credentials_feepayer); + // Sign same message as Fee payer + signedMessage = KaiaTransactionEncoder.signMessageAsFeePayer(raw, chainId, credentials_feepayer); - String hexValue = Numeric.toHexString(signedMessage); - EthSendTransaction transactionResponse = web3j.ethSendRawTransaction(hexValue).send(); - System.out.println("TxHash : \n " + transactionResponse.getResult()); - String txHash = transactionResponse.getResult(); + String hexValue = Numeric.toHexString(signedMessage); + EthSendTransaction transactionResponse = web3j.ethSendRawTransaction(hexValue).send(); + System.out.println("TxHash : \n " + transactionResponse.getResult()); + String txHash = transactionResponse.getResult(); - int DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH = 40; - int DEFAULT_BLOCK_TIME = 1 * 1000; - long DEFAULT_POLLING_FREQUENCY = DEFAULT_BLOCK_TIME; - TransactionReceiptProcessor transactionReceiptProcessor = new PollingTransactionReceiptProcessor(web3j, - DEFAULT_POLLING_FREQUENCY, DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH); - org.web3j.protocol.core.methods.response.TransactionReceipt ethReceipt = transactionReceiptProcessor - .waitForTransactionReceipt(txHash); - System.out.println("Receipt from eth_getTransactionReceipt : \n" + ethReceipt); - TransactionReceipt receipt = web3j.kaiaGetTransactionReceipt(txHash).send().getResult(); - System.out.println("Receipt from kaia_getTransactionReceipt : \n" + receipt); - web3j.shutdown(); + int DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH = 40; + int DEFAULT_BLOCK_TIME = 1 * 1000; + long DEFAULT_POLLING_FREQUENCY = DEFAULT_BLOCK_TIME; + TransactionReceiptProcessor transactionReceiptProcessor = new PollingTransactionReceiptProcessor(web3j, + DEFAULT_POLLING_FREQUENCY, DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH); + org.web3j.protocol.core.methods.response.TransactionReceipt ethReceipt = transactionReceiptProcessor + .waitForTransactionReceipt(txHash); + System.out.println("Receipt from eth_getTransactionReceipt : \n" + ethReceipt); + TransactionReceipt receipt = web3j.kaiaGetTransactionReceipt(txHash).send().getResult(); + System.out.println("Receipt from kaia_getTransactionReceipt : \n" + receipt); + web3j.shutdown(); - TxTypeFeeDelegatedValueTransfer rawTransaction = TxTypeFeeDelegatedValueTransfer - .decodeFromRawTransaction(hexValue); - System.out.println("TxType : " + rawTransaction.getKaiaType()); - } + TxTypeFeeDelegatedValueTransfer rawTransaction = TxTypeFeeDelegatedValueTransfer + .decodeFromRawTransaction(hexValue); + System.out.println("TxType : " + rawTransaction.getKaiaType()); + } } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedValueTransferMemoWithRatioExample.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedValueTransferMemoWithRatioExample.java index e1d3be175..acec62528 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedValueTransferMemoWithRatioExample.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedValueTransferMemoWithRatioExample.java @@ -10,6 +10,7 @@ import org.web3j.crypto.KaiaRawTransaction; import org.web3j.crypto.KaiaTransactionEncoder; import org.web3j.crypto.transaction.type.TxType; +import org.web3j.crypto.transaction.type.TxTypeFeeDelegatedValueTransferMemoWithRatio; import org.web3j.crypto.transaction.type.TxTypeValueTransfer; import org.web3j.crypto.transaction.type.TxType.Type; import org.web3j.protocol.core.DefaultBlockParameterName; @@ -40,7 +41,7 @@ public static void run() throws Exception { String data = "Kaia Web3j"; byte[] payload = data.getBytes(); - TxType.Type type = Type.FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO; + TxType.Type type = Type.FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO; KaiaRawTransaction raw = KaiaRawTransaction.createTransaction( type, @@ -75,7 +76,8 @@ public static void run() throws Exception { System.out.println("Receipt from kaia_getTransactionReceipt : \n" + receipt); web3j.shutdown(); - TxTypeValueTransfer rawTransaction = TxTypeValueTransfer.decodeFromRawTransaction(hexValue); + TxTypeFeeDelegatedValueTransferMemoWithRatio rawTransaction = TxTypeFeeDelegatedValueTransferMemoWithRatio + .decodeFromRawTransaction(hexValue); System.out.println("TxType : " + rawTransaction.getKaiaType()); } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedValueTransferWithRatioExample.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedValueTransferWithRatioExample.java index fc9ebdf07..b65358ad0 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedValueTransferWithRatioExample.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/FeeDelegatedValueTransferWithRatioExample.java @@ -10,6 +10,7 @@ import org.web3j.crypto.KaiaRawTransaction; import org.web3j.crypto.KaiaTransactionEncoder; import org.web3j.crypto.transaction.type.TxType; +import org.web3j.crypto.transaction.type.TxTypeFeeDelegatedValueTransferWithRatio; import org.web3j.crypto.transaction.type.TxTypeValueTransfer; import org.web3j.crypto.transaction.type.TxType.Type; import org.web3j.protocol.core.DefaultBlockParameterName; @@ -72,7 +73,8 @@ public static void run() throws Exception { System.out.println("Receipt from kaia_getTransactionReceipt : \n" + receipt); web3j.shutdown(); - TxTypeValueTransfer rawTransaction = TxTypeValueTransfer.decodeFromRawTransaction(hexValue); + TxTypeFeeDelegatedValueTransferWithRatio rawTransaction = TxTypeFeeDelegatedValueTransferWithRatio + .decodeFromRawTransaction(hexValue); System.out.println("TxType : " + rawTransaction.getKaiaType()); } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/KaiaRawTransactionManagerExample.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/KaiaRawTransactionManagerExample.java index 24514344a..d68da3178 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/KaiaRawTransactionManagerExample.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/KaiaRawTransactionManagerExample.java @@ -16,41 +16,42 @@ import org.web3j.tx.KaiaRawTransactionManager; public class KaiaRawTransactionManagerExample implements keySample { - /** - * - */ - - public static void run() throws Exception { - - Web3j web3j = Web3j.build(new HttpService(keySample.BAOBAB_URL)); - KaiaCredentials credentials = KaiaCredentials.create(keySample.LEGACY_KEY_privkey); - - BigInteger GAS_PRICE = BigInteger.valueOf(50000000000L); - BigInteger GAS_LIMIT = BigInteger.valueOf(6721950); - String from = credentials.getAddress(); - EthChainId EthchainId = web3j.ethChainId().send(); - long chainId = EthchainId.getChainId().longValue(); - String to = "0x000000000000000000000000000000000000dead"; - BigInteger value = BigInteger.valueOf(100); - - TxType.Type type = Type.VALUE_TRANSFER; - - KaiaRawTransactionManager manager = new KaiaRawTransactionManager(web3j, credentials, chainId); - EthSendTransaction transactionResponse = manager.sendKaiaTransaction(type, GAS_PRICE, GAS_LIMIT, to, value, - from); - System.out.println("TxHash : \n " + transactionResponse.getResult()); - String txHash = transactionResponse.getResult(); - - int DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH = 40; - int DEFAULT_BLOCK_TIME = 1 * 1000; - long DEFAULT_POLLING_FREQUENCY = DEFAULT_BLOCK_TIME; - TransactionReceiptProcessor transactionReceiptProcessor = new PollingTransactionReceiptProcessor(web3j, - DEFAULT_POLLING_FREQUENCY, DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH); - org.web3j.protocol.core.methods.response.TransactionReceipt ethReceipt = transactionReceiptProcessor - .waitForTransactionReceipt(txHash); - System.out.println("Receipt from eth_getTransactionReceipt : \n" + ethReceipt); - TransactionReceipt receipt = web3j.kaiaGetTransactionReceipt(txHash).send().getResult(); - System.out.println("Receipt from kaia_getTransactionReceipt : \n" + receipt); - web3j.shutdown(); - } + /** + * + */ + + public static void run() throws Exception { + + Web3j web3j = Web3j.build(new HttpService(keySample.BAOBAB_URL)); + KaiaCredentials credentials = KaiaCredentials.create(keySample.LEGACY_KEY_privkey); + + BigInteger GAS_PRICE = BigInteger.valueOf(50000000000L); + BigInteger GAS_LIMIT = BigInteger.valueOf(6721950); + String from = credentials.getAddress(); + EthChainId EthchainId = web3j.ethChainId().send(); + long chainId = EthchainId.getChainId().longValue(); + String to = "0x000000000000000000000000000000000000dead"; + BigInteger value = BigInteger.valueOf(100); + + TxType.Type type = Type.VALUE_TRANSFER; + + KaiaRawTransactionManager manager = new KaiaRawTransactionManager(web3j, credentials, chainId); + EthSendTransaction transactionResponse = manager.sendKaiaTransaction(type, GAS_PRICE, GAS_LIMIT, to, + value, + from); + System.out.println("TxHash : \n " + transactionResponse.getResult()); + String txHash = transactionResponse.getResult(); + + int DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH = 40; + int DEFAULT_BLOCK_TIME = 1 * 1000; + long DEFAULT_POLLING_FREQUENCY = DEFAULT_BLOCK_TIME; + TransactionReceiptProcessor transactionReceiptProcessor = new PollingTransactionReceiptProcessor(web3j, + DEFAULT_POLLING_FREQUENCY, DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH); + org.web3j.protocol.core.methods.response.TransactionReceipt ethReceipt = transactionReceiptProcessor + .waitForTransactionReceipt(txHash); + System.out.println("Receipt from eth_getTransactionReceipt : \n" + ethReceipt); + TransactionReceipt receipt = web3j.kaiaGetTransactionReceipt(txHash).send().getResult(); + System.out.println("Receipt from kaia_getTransactionReceipt : \n" + receipt); + web3j.shutdown(); + } } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/LegacyExample.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/LegacyExample.java index 81259bb6c..36fe9186a 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/LegacyExample.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/LegacyExample.java @@ -72,6 +72,12 @@ public static void run() throws Exception { org.web3j.protocol.core.methods.response.TransactionReceipt ethReceipt = transactionReceiptProcessor .waitForTransactionReceipt(txHash); System.out.println("Receipt from eth_getTransactionReceipt : \n" + ethReceipt); + + try { + Thread.sleep(2000); + } catch (Exception e) { + System.out.println(e); + } TransactionReceipt receipt = web3j.kaiaGetTransactionReceipt(txHash).send().getResult(); System.out.println("Receipt from kaia_getTransactionReceipt : \n" + receipt); web3j.shutdown(); diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/SmartContractDeployExample.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/SmartContractDeployExample.java index a8ebc66cb..7b643cab2 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/SmartContractDeployExample.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/SmartContractDeployExample.java @@ -23,62 +23,63 @@ * */ public class SmartContractDeployExample implements keySample { - /** - * - */ + /** + * + */ - public static void run() throws Exception { - Web3j web3j = Web3j.build(new HttpService(keySample.BAOBAB_URL)); - KaiaCredentials credentials = KaiaCredentials.create(keySample.LEGACY_KEY_privkey); + public static void run() throws Exception { + Web3j web3j = Web3j.build(new HttpService(keySample.BAOBAB_URL)); + KaiaCredentials credentials = KaiaCredentials.create(keySample.LEGACY_KEY_privkey); - BigInteger GAS_PRICE = BigInteger.valueOf(50000000000L); - BigInteger GAS_LIMIT = BigInteger.valueOf(6721950); - String from = credentials.getAddress(); - BigInteger nonce = web3j.ethGetTransactionCount(from, DefaultBlockParameterName.LATEST).send() - .getTransactionCount(); - String data = "0x60c0604052600c60809081526b48656c6c6f20576f726c642160a01b60a05260009061002b90826100dd565b5034801561003857600080fd5b5061019c565b634e487b7160e01b600052604160045260246000fd5b600181811c9082168061006857607f821691505b60208210810361008857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156100d857600081815260208120601f850160051c810160208610156100b55750805b601f850160051c820191505b818110156100d4578281556001016100c1565b5050505b505050565b81516001600160401b038111156100f6576100f661003e565b61010a816101048454610054565b8461008e565b602080601f83116001811461013f57600084156101275750858301515b600019600386901b1c1916600185901b1785556100d4565b600085815260208120601f198616915b8281101561016e5788860151825594840194600190910190840161014f565b508582101561018c5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b61019a806101ab6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063cfae321714610030575b600080fd5b61003861004e565b60405161004591906100dc565b60405180910390f35b6000805461005b9061012a565b80601f01602080910402602001604051908101604052809291908181526020018280546100879061012a565b80156100d45780601f106100a9576101008083540402835291602001916100d4565b820191906000526020600020905b8154815290600101906020018083116100b757829003601f168201915b505050505081565b600060208083528351808285015260005b81811015610109578581018301518582016040015282016100ed565b506000604082860101526040601f19601f8301168501019250505092915050565b600181811c9082168061013e57607f821691505b60208210810361015e57634e487b7160e01b600052602260045260246000fd5b5091905056fea264697066735822122002272dad43feb87cde6d15be86d8d1af21672f2443deb524dce07ca0210d1cec64736f6c63430008120033"; - EthChainId EthchainId = web3j.ethChainId().send(); - long chainId = EthchainId.getChainId().longValue(); - String to = null; - byte[] payload = Numeric.hexStringToByteArray(data); + BigInteger GAS_PRICE = BigInteger.valueOf(50000000000L); + BigInteger GAS_LIMIT = BigInteger.valueOf(6721950); + String from = credentials.getAddress(); + BigInteger nonce = web3j.ethGetTransactionCount(from, DefaultBlockParameterName.LATEST).send() + .getTransactionCount(); + String data = "0x60c0604052600c60809081526b48656c6c6f20576f726c642160a01b60a05260009061002b90826100dd565b5034801561003857600080fd5b5061019c565b634e487b7160e01b600052604160045260246000fd5b600181811c9082168061006857607f821691505b60208210810361008857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156100d857600081815260208120601f850160051c810160208610156100b55750805b601f850160051c820191505b818110156100d4578281556001016100c1565b5050505b505050565b81516001600160401b038111156100f6576100f661003e565b61010a816101048454610054565b8461008e565b602080601f83116001811461013f57600084156101275750858301515b600019600386901b1c1916600185901b1785556100d4565b600085815260208120601f198616915b8281101561016e5788860151825594840194600190910190840161014f565b508582101561018c5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b61019a806101ab6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063cfae321714610030575b600080fd5b61003861004e565b60405161004591906100dc565b60405180910390f35b6000805461005b9061012a565b80601f01602080910402602001604051908101604052809291908181526020018280546100879061012a565b80156100d45780601f106100a9576101008083540402835291602001916100d4565b820191906000526020600020905b8154815290600101906020018083116100b757829003601f168201915b505050505081565b600060208083528351808285015260005b81811015610109578581018301518582016040015282016100ed565b506000604082860101526040601f19601f8301168501019250505092915050565b600181811c9082168061013e57607f821691505b60208210810361015e57634e487b7160e01b600052602260045260246000fd5b5091905056fea264697066735822122002272dad43feb87cde6d15be86d8d1af21672f2443deb524dce07ca0210d1cec64736f6c63430008120033"; + EthChainId EthchainId = web3j.ethChainId().send(); + long chainId = EthchainId.getChainId().longValue(); + String to = null; + byte[] payload = Numeric.hexStringToByteArray(data); - BigInteger value = BigInteger.ZERO; - BigInteger codeFormat = BigInteger.ZERO; - TxType.Type type = Type.SMART_CONTRACT_DEPLOY; + BigInteger value = BigInteger.ZERO; + BigInteger codeFormat = BigInteger.ZERO; + TxType.Type type = Type.SMART_CONTRACT_DEPLOY; - KaiaRawTransaction raw = KaiaRawTransaction.createTransaction( - type, - nonce, - GAS_PRICE, - GAS_LIMIT, - to, - value, - from, - payload, - codeFormat); + KaiaRawTransaction raw = KaiaRawTransaction.createTransaction( + type, + nonce, + GAS_PRICE, + GAS_LIMIT, + to, + value, + from, + payload, + codeFormat); - byte[] signedMessage = KaiaTransactionEncoder.signMessage(raw, chainId, credentials); - String hexValue = Numeric.toHexString(signedMessage); - EthSendTransaction transactionResponse = web3j.ethSendRawTransaction(hexValue).send(); - System.out.println("TxHash : \n " + transactionResponse.getResult()); - String txHash = transactionResponse.getResult(); + byte[] signedMessage = KaiaTransactionEncoder.signMessage(raw, chainId, credentials); + String hexValue = Numeric.toHexString(signedMessage); + EthSendTransaction transactionResponse = web3j.ethSendRawTransaction(hexValue).send(); + System.out.println("TxHash : \n " + transactionResponse.getResult()); + String txHash = transactionResponse.getResult(); - int DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH = 40; - int DEFAULT_BLOCK_TIME = 1 * 1000; - long DEFAULT_POLLING_FREQUENCY = DEFAULT_BLOCK_TIME; - TransactionReceiptProcessor transactionReceiptProcessor = new PollingTransactionReceiptProcessor(web3j, - DEFAULT_POLLING_FREQUENCY, DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH); - org.web3j.protocol.core.methods.response.TransactionReceipt ethReceipt = transactionReceiptProcessor - .waitForTransactionReceipt(txHash); - System.out.println("Receipt from eth_getTransactionReceipt : \n" + ethReceipt); - TransactionReceipt receipt = web3j.kaiaGetTransactionReceipt(txHash).send().getResult(); - System.out.println("Receipt from kaia_getTransactionReceipt : \n" + receipt); - web3j.shutdown(); + int DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH = 40; + int DEFAULT_BLOCK_TIME = 1 * 1000; + long DEFAULT_POLLING_FREQUENCY = DEFAULT_BLOCK_TIME; + TransactionReceiptProcessor transactionReceiptProcessor = new PollingTransactionReceiptProcessor(web3j, + DEFAULT_POLLING_FREQUENCY, DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH); + org.web3j.protocol.core.methods.response.TransactionReceipt ethReceipt = transactionReceiptProcessor + .waitForTransactionReceipt(txHash); + System.out.println("Receipt from eth_getTransactionReceipt : \n" + ethReceipt); + TransactionReceipt receipt = web3j.kaiaGetTransactionReceipt(txHash).send().getResult(); + System.out.println("Receipt from kaia_getTransactionReceipt : \n" + receipt); + web3j.shutdown(); - TxTypeSmartContractDeploy rawTransaction = TxTypeSmartContractDeploy.decodeFromRawTransaction(signedMessage); + TxTypeSmartContractDeploy rawTransaction = TxTypeSmartContractDeploy + .decodeFromRawTransaction(signedMessage); - System.out.println("TxType : " + rawTransaction.getKaiaType()); + System.out.println("TxType : " + rawTransaction.getKaiaType()); - } + } } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/ValueTransferExample.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/ValueTransferExample.java index d32517884..a37943160 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/ValueTransferExample.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/ValueTransferExample.java @@ -23,55 +23,55 @@ * */ public class ValueTransferExample implements keySample { - /** - * - */ + /** + * + */ - public static void run() throws Exception { - Web3j web3j = Web3j.build(new HttpService(keySample.BAOBAB_URL)); - KaiaCredentials credentials = KaiaCredentials.create(keySample.LEGACY_KEY_privkey); + public static void run() throws Exception { + Web3j web3j = Web3j.build(new HttpService(keySample.BAOBAB_URL)); + KaiaCredentials credentials = KaiaCredentials.create(keySample.LEGACY_KEY_privkey); - BigInteger GAS_PRICE = BigInteger.valueOf(50000000000L); - BigInteger GAS_LIMIT = BigInteger.valueOf(6721950); - String from = credentials.getAddress(); - EthChainId EthchainId = web3j.ethChainId().send(); - long chainId = EthchainId.getChainId().longValue(); - String to = "0x000000000000000000000000000000000000dead"; - BigInteger nonce = web3j.ethGetTransactionCount(from, DefaultBlockParameterName.LATEST).send() - .getTransactionCount(); - BigInteger value = BigInteger.valueOf(100); + BigInteger GAS_PRICE = BigInteger.valueOf(50000000000L); + BigInteger GAS_LIMIT = BigInteger.valueOf(6721950); + String from = credentials.getAddress(); + EthChainId EthchainId = web3j.ethChainId().send(); + long chainId = EthchainId.getChainId().longValue(); + String to = "0x000000000000000000000000000000000000dead"; + BigInteger nonce = web3j.ethGetTransactionCount(from, DefaultBlockParameterName.LATEST).send() + .getTransactionCount(); + BigInteger value = BigInteger.valueOf(100); - TxType.Type type = Type.VALUE_TRANSFER; + TxType.Type type = Type.VALUE_TRANSFER; - KaiaRawTransaction raw = KaiaRawTransaction.createTransaction( - type, - nonce, - GAS_PRICE, - GAS_LIMIT, - to, - value, - from); + KaiaRawTransaction raw = KaiaRawTransaction.createTransaction( + type, + nonce, + GAS_PRICE, + GAS_LIMIT, + to, + value, + from); - byte[] signedMessage = KaiaTransactionEncoder.signMessage(raw, chainId, credentials); - String hexValue = Numeric.toHexString(signedMessage); - EthSendTransaction transactionResponse = web3j.ethSendRawTransaction(hexValue).send(); - System.out.println("TxHash : \n " + transactionResponse.getResult()); - String txHash = transactionResponse.getResult(); + byte[] signedMessage = KaiaTransactionEncoder.signMessage(raw, chainId, credentials); + String hexValue = Numeric.toHexString(signedMessage); + EthSendTransaction transactionResponse = web3j.ethSendRawTransaction(hexValue).send(); + System.out.println("TxHash : \n " + transactionResponse.getResult()); + String txHash = transactionResponse.getResult(); - int DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH = 40; - int DEFAULT_BLOCK_TIME = 1 * 1000; - long DEFAULT_POLLING_FREQUENCY = DEFAULT_BLOCK_TIME; - TransactionReceiptProcessor transactionReceiptProcessor = new PollingTransactionReceiptProcessor(web3j, - DEFAULT_POLLING_FREQUENCY, DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH); - org.web3j.protocol.core.methods.response.TransactionReceipt ethReceipt = transactionReceiptProcessor - .waitForTransactionReceipt(txHash); - System.out.println("Receipt from eth_getTransactionReceipt : \n" + ethReceipt); - TransactionReceipt receipt = web3j.kaiaGetTransactionReceipt(txHash).send().getResult(); - System.out.println("Receipt from kaia_getTransactionReceipt : \n" + receipt); - web3j.shutdown(); + int DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH = 40; + int DEFAULT_BLOCK_TIME = 1 * 1000; + long DEFAULT_POLLING_FREQUENCY = DEFAULT_BLOCK_TIME; + TransactionReceiptProcessor transactionReceiptProcessor = new PollingTransactionReceiptProcessor(web3j, + DEFAULT_POLLING_FREQUENCY, DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH); + org.web3j.protocol.core.methods.response.TransactionReceipt ethReceipt = transactionReceiptProcessor + .waitForTransactionReceipt(txHash); + System.out.println("Receipt from eth_getTransactionReceipt : \n" + ethReceipt); + TransactionReceipt receipt = web3j.kaiaGetTransactionReceipt(txHash).send().getResult(); + System.out.println("Receipt from kaia_getTransactionReceipt : \n" + receipt); + web3j.shutdown(); - TxTypeValueTransfer rawTransaction = TxTypeValueTransfer.decodeFromRawTransaction(signedMessage); - System.out.println("TxType : " + rawTransaction.getKaiaType()); - } + TxTypeValueTransfer rawTransaction = TxTypeValueTransfer.decodeFromRawTransaction(signedMessage); + System.out.println("TxType : " + rawTransaction.getKaiaType()); + } } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/ValueTransferMemoExample.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/ValueTransferMemoExample.java index 012a28954..fb0aa40a1 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/ValueTransferMemoExample.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/transactions/ValueTransferMemoExample.java @@ -23,60 +23,61 @@ * */ public class ValueTransferMemoExample implements keySample { - /** - * - */ + /** + * + */ - public static void run() throws Exception { + public static void run() throws Exception { - Web3j web3j = Web3j.build(new HttpService(keySample.BAOBAB_URL)); - KaiaCredentials credentials = KaiaCredentials.create(keySample.LEGACY_KEY_privkey); + Web3j web3j = Web3j.build(new HttpService(keySample.BAOBAB_URL)); + KaiaCredentials credentials = KaiaCredentials.create(keySample.LEGACY_KEY_privkey); - BigInteger GAS_PRICE = BigInteger.valueOf(50000000000L); - BigInteger GAS_LIMIT = BigInteger.valueOf(6721950); - String from = credentials.getAddress(); - EthChainId EthchainId = web3j.ethChainId().send(); - long chainId = EthchainId.getChainId().longValue(); - String to = "0x000000000000000000000000000000000000dead"; - BigInteger nonce = web3j.ethGetTransactionCount(from, DefaultBlockParameterName.LATEST).send() - .getTransactionCount(); - BigInteger value = BigInteger.valueOf(100); + BigInteger GAS_PRICE = BigInteger.valueOf(50000000000L); + BigInteger GAS_LIMIT = BigInteger.valueOf(6721950); + String from = credentials.getAddress(); + EthChainId EthchainId = web3j.ethChainId().send(); + long chainId = EthchainId.getChainId().longValue(); + String to = "0x000000000000000000000000000000000000dead"; + BigInteger nonce = web3j.ethGetTransactionCount(from, DefaultBlockParameterName.LATEST).send() + .getTransactionCount(); + BigInteger value = BigInteger.valueOf(100); - String data = "Kaia Web3j"; - byte[] payload = data.getBytes(); + String data = "Kaia Web3j"; + byte[] payload = data.getBytes(); - TxType.Type type = Type.VALUE_TRANSFER_MEMO; + TxType.Type type = Type.VALUE_TRANSFER_MEMO; - KaiaRawTransaction raw = KaiaRawTransaction.createTransaction( - type, - nonce, - GAS_PRICE, - GAS_LIMIT, - to, - value, - from, - payload); + KaiaRawTransaction raw = KaiaRawTransaction.createTransaction( + type, + nonce, + GAS_PRICE, + GAS_LIMIT, + to, + value, + from, + payload); - byte[] signedMessage = KaiaTransactionEncoder.signMessage(raw, chainId, credentials); - String hexValue = Numeric.toHexString(signedMessage); - EthSendTransaction transactionResponse = web3j.ethSendRawTransaction(hexValue).send(); - System.out.println("TxHash : \n " + transactionResponse.getResult()); - String txHash = transactionResponse.getResult(); + byte[] signedMessage = KaiaTransactionEncoder.signMessage(raw, chainId, credentials); + String hexValue = Numeric.toHexString(signedMessage); + EthSendTransaction transactionResponse = web3j.ethSendRawTransaction(hexValue).send(); + System.out.println("TxHash : \n " + transactionResponse.getResult()); + String txHash = transactionResponse.getResult(); - int DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH = 40; - int DEFAULT_BLOCK_TIME = 1 * 1000; - long DEFAULT_POLLING_FREQUENCY = DEFAULT_BLOCK_TIME; - TransactionReceiptProcessor transactionReceiptProcessor = new PollingTransactionReceiptProcessor(web3j, - DEFAULT_POLLING_FREQUENCY, DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH); - org.web3j.protocol.core.methods.response.TransactionReceipt ethReceipt = transactionReceiptProcessor - .waitForTransactionReceipt(txHash); - System.out.println("Receipt from eth_getTransactionReceipt : \n" + ethReceipt); - TransactionReceipt receipt = web3j.kaiaGetTransactionReceipt(txHash).send().getResult(); - System.out.println("Receipt from kaia_getTransactionReceipt : \n" + receipt); - web3j.shutdown(); + int DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH = 40; + int DEFAULT_BLOCK_TIME = 1 * 1000; + long DEFAULT_POLLING_FREQUENCY = DEFAULT_BLOCK_TIME; + TransactionReceiptProcessor transactionReceiptProcessor = new PollingTransactionReceiptProcessor(web3j, + DEFAULT_POLLING_FREQUENCY, DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH); + org.web3j.protocol.core.methods.response.TransactionReceipt ethReceipt = transactionReceiptProcessor + .waitForTransactionReceipt(txHash); + System.out.println("Receipt from eth_getTransactionReceipt : \n" + ethReceipt); + TransactionReceipt receipt = web3j.kaiaGetTransactionReceipt(txHash).send().getResult(); + System.out.println("Receipt from kaia_getTransactionReceipt : \n" + receipt); + web3j.shutdown(); - TxTypeValueTransferMemo rawTransaction = TxTypeValueTransferMemo.decodeFromRawTransaction(signedMessage); - System.out.println("TxType : " + rawTransaction.getKaiaType()); - } + TxTypeValueTransferMemo rawTransaction = TxTypeValueTransferMemo + .decodeFromRawTransaction(signedMessage); + System.out.println("TxType : " + rawTransaction.getKaiaType()); + } } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/utils/DecryptKeystoreV3Example.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/utils/DecryptKeystoreV3Example.java index 366ba092e..b748b8947 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/utils/DecryptKeystoreV3Example.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/utils/DecryptKeystoreV3Example.java @@ -15,7 +15,7 @@ public class DecryptKeystoreV3Example implements keySample { public static void run() throws Exception { - String password = "Ilovekaia"; + String password = "Iloveklaytn"; String[] keyFiles = { "/Legacy_V3.json", "/Public_V3.json" }; for (String keyFile : keyFiles) { diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/utils/DecryptKeystoreV4Example.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/utils/DecryptKeystoreV4Example.java index 4fd9efe9f..388ed5d31 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/utils/DecryptKeystoreV4Example.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/utils/DecryptKeystoreV4Example.java @@ -16,7 +16,7 @@ public class DecryptKeystoreV4Example implements keySample { public static void run() throws Exception { - String password = "Ilovekaia"; + String password = "Iloveklaytn"; String[] keyFiles = { "/RoleBased_V4.json", "/Multi_V4.json", "/Public_V4.json" }; for (String keyFile : keyFiles) { diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/utils/FillTransactionExample.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/utils/FillTransactionExample.java index 6220e5995..aae1a95c1 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/example/utils/FillTransactionExample.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/example/utils/FillTransactionExample.java @@ -21,56 +21,56 @@ * */ public class FillTransactionExample implements keySample { - /** - * - */ + /** + * + */ - public static void run() throws Exception { - Web3j web3j = Web3j.build(new HttpService(keySample.BAOBAB_URL)); - KaiaCredentials credentials = KaiaCredentials.create(keySample.LEGACY_KEY_privkey); + public static void run() throws Exception { + Web3j web3j = Web3j.build(new HttpService(keySample.BAOBAB_URL)); + KaiaCredentials credentials = KaiaCredentials.create(keySample.LEGACY_KEY_privkey); - BigInteger GAS_LIMIT = BigInteger.valueOf(6721950); - String from = credentials.getAddress(); - String to = "0x000000000000000000000000000000000000dead"; + BigInteger GAS_LIMIT = BigInteger.valueOf(6721950); + String from = credentials.getAddress(); + String to = "0x000000000000000000000000000000000000dead"; - BigInteger value = BigInteger.valueOf(100); + BigInteger value = BigInteger.valueOf(100); - TxType.Type type = Type.VALUE_TRANSFER; + TxType.Type type = Type.VALUE_TRANSFER; - KaiaRawTransaction raw = KaiaRawTransaction.createTransaction( - 0, // set chainId to zero - type, - BigInteger.ZERO, // set nonce to zero - BigInteger.ZERO, // set Gas price to zero - GAS_LIMIT, - to, - value, - from); + KaiaRawTransaction raw = KaiaRawTransaction.createTransaction( + 0, // set chainId to zero + type, + BigInteger.ZERO, // set nonce to zero + BigInteger.ZERO, // set Gas price to zero + GAS_LIMIT, + to, + value, + from); - // Fill transaction with fillTransaction - KaiaRawTransaction raw_fillTransaction = raw.fillTransaction(web3j); + // Fill transaction with fillTransaction + KaiaRawTransaction raw_fillTransaction = raw.fillTransaction(web3j); - byte[] signedMessage = KaiaTransactionEncoder.signMessage(raw_fillTransaction, credentials); - String hexValue = Numeric.toHexString(signedMessage); - EthSendTransaction transactionResponse = web3j.ethSendRawTransaction(hexValue).send(); - System.out.println("TxHash : \n " + transactionResponse.getResult()); - String txHash = transactionResponse.getResult(); + byte[] signedMessage = KaiaTransactionEncoder.signMessage(raw_fillTransaction, credentials); + String hexValue = Numeric.toHexString(signedMessage); + EthSendTransaction transactionResponse = web3j.ethSendRawTransaction(hexValue).send(); + System.out.println("TxHash : \n " + transactionResponse.getResult()); + String txHash = transactionResponse.getResult(); - int DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH = 40; - int DEFAULT_BLOCK_TIME = 1 * 1000; - long DEFAULT_POLLING_FREQUENCY = DEFAULT_BLOCK_TIME; - TransactionReceiptProcessor transactionReceiptProcessor = new PollingTransactionReceiptProcessor(web3j, - DEFAULT_POLLING_FREQUENCY, DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH); - org.web3j.protocol.core.methods.response.TransactionReceipt ethReceipt = transactionReceiptProcessor - .waitForTransactionReceipt(txHash); - System.out.println("Receipt from eth_getTransactionReceipt : \n" + ethReceipt); - TransactionReceipt receipt = web3j.kaiaGetTransactionReceipt(txHash).send().getResult(); - System.out.println("Receipt from kaia_getTransactionReceipt : \n" + receipt); - web3j.shutdown(); + int DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH = 40; + int DEFAULT_BLOCK_TIME = 1 * 1000; + long DEFAULT_POLLING_FREQUENCY = DEFAULT_BLOCK_TIME; + TransactionReceiptProcessor transactionReceiptProcessor = new PollingTransactionReceiptProcessor(web3j, + DEFAULT_POLLING_FREQUENCY, DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH); + org.web3j.protocol.core.methods.response.TransactionReceipt ethReceipt = transactionReceiptProcessor + .waitForTransactionReceipt(txHash); + System.out.println("Receipt from eth_getTransactionReceipt : \n" + ethReceipt); + TransactionReceipt receipt = web3j.kaiaGetTransactionReceipt(txHash).send().getResult(); + System.out.println("Receipt from kaia_getTransactionReceipt : \n" + receipt); + web3j.shutdown(); - TxTypeValueTransfer rawTransaction = TxTypeValueTransfer.decodeFromRawTransaction(signedMessage); - System.out.println("TxType : " + rawTransaction.getKaiaType()); + TxTypeValueTransfer rawTransaction = TxTypeValueTransfer.decodeFromRawTransaction(signedMessage); + System.out.println("TxType : " + rawTransaction.getKaiaType()); - } + } } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/klayAccount/AccountInfo.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/kaiaAccount/AccountInfo.java similarity index 75% rename from web3j-ext/web3j-ext/src/main/java/org/web3j/klayAccount/AccountInfo.java rename to web3j-ext/web3j-ext/src/main/java/org/web3j/kaiaAccount/AccountInfo.java index 3d4488f8a..75dfaad6a 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/klayAccount/AccountInfo.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/kaiaAccount/AccountInfo.java @@ -9,23 +9,22 @@ public class AccountInfo { private String address; - private String balance="0x0"; + private String balance = "0x0"; private BigDecimal nonce = BigDecimal.ZERO; public JSONObject key; - - + public AccountInfo() { } - + public AccountInfo(String address) { this.address = address; } - + public AccountInfo(String address, JSONObject key) { this.address = address; this.key = key; } - + public AccountInfo(String address, String balance, BigDecimal nonce, JSONObject key) { this.address = address; this.balance = balance; @@ -33,39 +32,36 @@ public AccountInfo(String address, String balance, BigDecimal nonce, JSONObject this.key = key; } - public JSONObject getKey() { return key; } - + public int getKeyType() { return (int) key.get("keyType"); - + } - - public static JSONObject getKeyJSON(JSONObject jsonKey, Accounts accountlist ) { - - if( !jsonKey.has("key")) { + + public static JSONObject getKeyJSON(JSONObject jsonKey, Accounts accountlist) { + + if (!jsonKey.has("key")) { return null; } int type = 2; - if( jsonKey.has("keyType")) { + if (jsonKey.has("keyType")) { type = jsonKey.getInt("keyType"); } - - if(type == 1) { + + if (type == 1) { ((JSONObject) jsonKey.get("key")).put("keyType", type); ((JSONObject) jsonKey.get("key")).put("key", new JSONObject()); return jsonKey; } - - - - else if(type == 2) { + + else if (type == 2) { String x = jsonKey.getJSONObject("key").getString("x"); String y = jsonKey.getJSONObject("key").getString("y"); - AccountKeyPublic accountPublic = AccountKeyPublic.create(x,y); + AccountKeyPublic accountPublic = AccountKeyPublic.create(x, y); String compressed = accountPublic.toCompressedPublicKey(); String hashed = addHexPrefix(Keys.getAddress(accountPublic.getPublicKey())); boolean hasPrivKey = !accountlist.credentialsByPubKey(accountPublic.getPublicKey()).isEmpty(); @@ -80,29 +76,27 @@ else if(type == 2) { return jsonKey; } - - else if(type == 4) { + + else if (type == 4) { JSONArray keys = jsonKey.getJSONObject("key").getJSONArray("keys"); - for(int n = 0; n < keys.length(); n++) - { - JSONObject object = keys.getJSONObject(n); - JSONObject result = getKeyJSON(object, accountlist); - + for (int n = 0; n < keys.length(); n++) { + JSONObject object = keys.getJSONObject(n); + JSONObject result = getKeyJSON(object, accountlist); + object.put("pubkey", result.getJSONObject("key").getJSONObject("pubkey")); object.remove("key"); } return jsonKey; - - } - else if(type == 5) { + + } else if (type == 5) { JSONArray keys = jsonKey.getJSONArray("key"); JSONObject jsonKeys = new JSONObject(); - + JSONObject transaction = keys.getJSONObject(0); JSONObject update = keys.getJSONObject(1); JSONObject fee = keys.getJSONObject(2); - + jsonKeys.put("RoleTransaction", getKeyJSON(transaction, accountlist)); jsonKeys.put("RoleAccountUpdate", getKeyJSON(update, accountlist)); jsonKeys.put("RoleFeePayer", getKeyJSON(fee, accountlist)); @@ -110,39 +104,35 @@ else if(type == 5) { jsonKey.remove("key"); jsonKey.put("key", jsonKeys); - return jsonKey; - - + } - + return null; - + } - + public JSONObject getByJSON() { JSONObject jsonAll = new JSONObject(); jsonAll.put("address", this.address); jsonAll.put("balance", this.balance); jsonAll.put("nonce", this.nonce); - if ( this.key.has("key")) { - jsonAll.put("key", this.key.get("key")); + if (this.key.has("key")) { + jsonAll.put("key", this.key.get("key")); } return jsonAll; - + + } + + public static String addHexPrefix(String str) { + if (!isHexPrefixed(str)) { + return "0x" + str; + } + return "0x" + str.substring(2); } - - public static String addHexPrefix(String str) { - if(!isHexPrefixed(str)) { - return "0x" + str; - } - return "0x" + str.substring(2); - } - - static boolean isHexPrefixed(String str) { - return !Strings.isEmpty(str) && (str.startsWith("0x") || str.startsWith("0X")); - } - - - + + static boolean isHexPrefixed(String str) { + return !Strings.isEmpty(str) && (str.startsWith("0x") || str.startsWith("0X")); + } + } \ No newline at end of file diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/klayAccount/AccountStore.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/kaiaAccount/AccountStore.java similarity index 96% rename from web3j-ext/web3j-ext/src/main/java/org/web3j/klayAccount/AccountStore.java rename to web3j-ext/web3j-ext/src/main/java/org/web3j/kaiaAccount/AccountStore.java index 2e52335a7..b3fb3b6c9 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/klayAccount/AccountStore.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/kaiaAccount/AccountStore.java @@ -51,7 +51,8 @@ public boolean refresh(Web3j web3j, Accounts list) throws IOException { JSONObject jsonKey = AccountInfo.getKeyJSON(jsonAccount.getJSONObject("key"), list); if (jsonKey != null) { - AccountInfo accountInfo = new AccountInfo(element, acc.getAccount().getBalance(), acc.getAccount().getNonce(), jsonKey); + AccountInfo accountInfo = new AccountInfo(element, acc.getAccount().getBalance(), + acc.getAccount().getNonce(), jsonKey); this.AccountLists.put(element, accountInfo); } } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/klayAccount/Accounts.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/kaiaAccount/Accounts.java similarity index 99% rename from web3j-ext/web3j-ext/src/main/java/org/web3j/klayAccount/Accounts.java rename to web3j-ext/web3j-ext/src/main/java/org/web3j/kaiaAccount/Accounts.java index b7c774060..2dd77751c 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/klayAccount/Accounts.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/kaiaAccount/Accounts.java @@ -37,7 +37,7 @@ public List credentialsByKey(BigInteger privKey) { } return returnKaiaCredentials; } - + public List credentialsByPubKey(BigInteger pubKey) { List returnKaiaCredentials = new ArrayList<>(); for (KaiaCredentials element : CredentialLists) { @@ -58,8 +58,4 @@ public List credentialsByAddress(String address) { return returnKaiaCredentials; } - - - - } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/protocol/kaia/Web3j.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/protocol/kaia/Web3j.java index 8c85466a8..18715306e 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/protocol/kaia/Web3j.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/protocol/kaia/Web3j.java @@ -1,4 +1,5 @@ package org.web3j.protocol.kaia; + import java.util.Arrays; import java.util.concurrent.ScheduledExecutorService; @@ -17,8 +18,8 @@ import org.web3j.protocol.kaia.core.TxpoolApi; import org.web3j.protocol.kaia.core.KaiaApi; - -public class Web3j extends JsonRpc2_0Web3j implements KaiaApi, KlayApi, GovernanceApi, AdminApi, NetApi, PersonalApi, TxpoolApi, DebugApi{ +public class Web3j extends JsonRpc2_0Web3j + implements KaiaApi, KlayApi, GovernanceApi, AdminApi, NetApi, PersonalApi, TxpoolApi, DebugApi { public static final int DEFAULT_BLOCK_TIME = 15 * 1000; public Web3j(Web3jService web3jService) { @@ -45,10 +46,13 @@ public static Web3j build(Web3jService web3jService) { /** * Construct a new Web3j instance. * - * @param web3jService web3j service instance - i.e. HTTP or IPC - * @param pollingInterval polling interval for responses from network nodes - * @param scheduledExecutorService executor service to use for scheduled tasks. You are - * responsible for terminating this thread pool + * @param web3jService web3j service instance - i.e. HTTP or IPC + * @param pollingInterval polling interval for responses from network + * nodes + * @param scheduledExecutorService executor service to use for scheduled tasks. + * You are + * responsible for terminating this thread + * pool * @return new Web3j instance */ public static Web3j build( @@ -67,12 +71,12 @@ public Request ethSendRawTransaction(String signedTransac // something } // Kaia transaction type - if(8 <= txType && txType <= 74) { + if (8 <= txType && txType <= 74) { return new Request<>( - "kaia_sendRawTransaction", - Arrays.asList(signedTransactionData), - web3jService, - org.web3j.protocol.core.methods.response.EthSendTransaction.class); + "kaia_sendRawTransaction", + Arrays.asList(signedTransactionData), + web3jService, + org.web3j.protocol.core.methods.response.EthSendTransaction.class); } return super.ethSendRawTransaction(signedTransactionData); } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/service/TxKaiaSignServiceImpl.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/service/TxKaiaSignServiceImpl.java index 7adb8e1a5..711c79db4 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/service/TxKaiaSignServiceImpl.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/service/TxKaiaSignServiceImpl.java @@ -1,15 +1,3 @@ -/* - * Copyright 2022 Web3 Labs Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ package org.web3j.service; import org.web3j.crypto.Credentials; @@ -21,7 +9,7 @@ import org.web3j.tx.ChainId; /** Service to base sign transaction. */ -public class TxKaiaSignServiceImpl{ +public class TxKaiaSignServiceImpl { private final KaiaCredentials credentials; @@ -55,8 +43,6 @@ public byte[] sign(RawTransaction rawTransaction, long chainId) { return signedMessage; } - - public String getAddress() { return credentials.getAddress(); } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/tx/KaiaRawTransactionManager.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/tx/KaiaRawTransactionManager.java index c8233a77e..d64894023 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/tx/KaiaRawTransactionManager.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/tx/KaiaRawTransactionManager.java @@ -1,15 +1,3 @@ -/* - * Copyright 2019 Web3 Labs Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ package org.web3j.tx; import java.io.IOException; @@ -38,11 +26,15 @@ import org.web3j.utils.TxHashVerifier; /** - * TransactionManager implementation using Ethereum wallet file to create and sign transactions + * TransactionManager implementation using Ethereum wallet file to create and + * sign transactions * locally. * - *

This transaction manager provides support for specifying the chain id for transactions as per - * EIP155, as well as for locally signing + *

+ * This transaction manager provides support for specifying the chain id for + * transactions as per + * EIP155, as well as + * for locally signing * RawTransaction instances without broadcasting them. */ public class KaiaRawTransactionManager extends TransactionManager { @@ -94,6 +86,7 @@ public KaiaRawTransactionManager( this.chainId = chainId; this.txSignService = new TxKaiaSignServiceImpl(credentials); } + public KaiaRawTransactionManager( Web3j web3j, KaiaCredentials credentials, long chainId, int attempts, long sleepDuration) { super(web3j, attempts, sleepDuration, credentials.getAddress()); @@ -102,6 +95,7 @@ public KaiaRawTransactionManager( this.chainId = chainId; this.txSignService = new TxKaiaSignServiceImpl(credentials); } + public KaiaRawTransactionManager(Web3j web3j, Credentials credentials) { this(web3j, credentials, ChainId.NONE); } @@ -112,10 +106,9 @@ public KaiaRawTransactionManager( } protected BigInteger getNonce() throws IOException { - EthGetTransactionCount ethGetTransactionCount = - web3j.ethGetTransactionCount( - this.getFromAddress(), DefaultBlockParameterName.PENDING) - .send(); + EthGetTransactionCount ethGetTransactionCount = web3j.ethGetTransactionCount( + this.getFromAddress(), DefaultBlockParameterName.PENDING) + .send(); return ethGetTransactionCount.getTransactionCount(); } @@ -128,15 +121,13 @@ public void setTxHashVerifier(TxHashVerifier txHashVerifier) { this.txHashVerifier = txHashVerifier; } - @Override public String sendCall(String to, String data, DefaultBlockParameter defaultBlockParameter) throws IOException { - EthCall ethCall = - web3j.ethCall( - Transaction.createEthCallTransaction(getFromAddress(), to, data), - defaultBlockParameter) - .send(); + EthCall ethCall = web3j.ethCall( + Transaction.createEthCallTransaction(getFromAddress(), to, data), + defaultBlockParameter) + .send(); assertCallNotReverted(ethCall); return ethCall.getValue(); @@ -149,10 +140,9 @@ public EthGetCode getCode( return web3j.ethGetCode(contractAddress, defaultBlockParameter).send(); } - - /* * @param rawTransaction a RawTransaction istance to be signed + * * @return The transaction signed and encoded without ever broadcasting it */ public String sign(KaiaRawTransaction rawTransaction) { @@ -176,9 +166,10 @@ public EthSendTransaction signAndSend(KaiaRawTransaction rawTransaction) throws return ethSendTransaction; } - + /* * @param rawTransaction a RawTransaction istance to be signed + * * @return The transaction signed and encoded without ever broadcasting it */ public String sign(RawTransaction rawTransaction) { @@ -208,8 +199,7 @@ public EthSendTransaction sendTransaction(BigInteger gasPrice, BigInteger gasLim BigInteger value, boolean constructor) throws IOException { BigInteger nonce = getNonce(); - RawTransaction rawTransaction = - RawTransaction.createTransaction(nonce, gasPrice, gasLimit, to, value, data); + RawTransaction rawTransaction = RawTransaction.createTransaction(nonce, gasPrice, gasLimit, to, value, data); return signAndSend(rawTransaction); } @@ -220,37 +210,34 @@ public EthSendTransaction sendEIP1559Transaction(long chainId, BigInteger maxPri throws IOException { BigInteger nonce = getNonce(); - RawTransaction rawTransaction = - RawTransaction.createTransaction( - chainId, - nonce, - gasLimit, - to, - value, - data, - maxPriorityFeePerGas, - maxFeePerGas); + RawTransaction rawTransaction = RawTransaction.createTransaction( + chainId, + nonce, + gasLimit, + to, + value, + data, + maxPriorityFeePerGas, + maxFeePerGas); return signAndSend(rawTransaction); } - - - + public EthSendTransaction sendKaiaTransaction( TxType.Type type, BigInteger gasPrice, BigInteger gas, String from, AccountKey accountKey) throws IOException { - + BigInteger nonce = getNonce(); KaiaRawTransaction rawTransaction = KaiaRawTransaction.createTransaction( - type, - nonce, - gasPrice, - gas, - from, - accountKey); + type, + nonce, + gasPrice, + gas, + from, + accountKey); return signAndSend(rawTransaction); } @@ -262,14 +249,13 @@ public EthSendTransaction sendKaiaTransaction( BigInteger nonce = getNonce(); KaiaRawTransaction rawTransaction = KaiaRawTransaction.createTransaction( - type, - nonce, - gasPrice, - gas, - from); - + type, + nonce, + gasPrice, + gas, + from); + return signAndSend(rawTransaction); - } @@ -283,15 +269,14 @@ public EthSendTransaction sendKaiaTransaction( BigInteger nonce = getNonce(); KaiaRawTransaction rawTransaction = KaiaRawTransaction.createTransaction( - type, - nonce, - gasPrice, - gas, - to, - value, - from); + type, + nonce, + gasPrice, + gas, + to, + value, + from); return signAndSend(rawTransaction); - } @@ -303,21 +288,20 @@ public EthSendTransaction sendKaiaTransaction( BigInteger value, String from, byte[] payload) throws IOException { - + BigInteger nonce = getNonce(); KaiaRawTransaction rawTransaction = KaiaRawTransaction.createTransaction( - type, - nonce, - gasPrice, - gas, - to, - value, - from, - payload); + type, + nonce, + gasPrice, + gas, + to, + value, + from, + payload); return signAndSend(rawTransaction); - - } + } public EthSendTransaction sendKaiaTransaction( TxType.Type type, @@ -328,25 +312,21 @@ public EthSendTransaction sendKaiaTransaction( String from, byte[] payload, BigInteger option) throws IOException { - BigInteger nonce = getNonce(); KaiaRawTransaction rawTransaction = KaiaRawTransaction.createTransaction( - type, - nonce, - gasPrice, - gas, - to, - value, - from, - payload, - option); + type, + nonce, + gasPrice, + gas, + to, + value, + from, + payload, + option); return signAndSend(rawTransaction); - - } - - + } public EthSendTransaction sendKaiaTransaction( TxType.Type type, @@ -355,22 +335,19 @@ public EthSendTransaction sendKaiaTransaction( String from, AccountKey accountKey, BigInteger feeRatio) throws IOException { - BigInteger nonce = getNonce(); KaiaRawTransaction rawTransaction = KaiaRawTransaction.createTransaction( - type, - nonce, - gasPrice, - gas, - from, - accountKey, - feeRatio); - - return signAndSend(rawTransaction); - } - + type, + nonce, + gasPrice, + gas, + from, + accountKey, + feeRatio); + return signAndSend(rawTransaction); + } public EthSendTransaction sendKaiaTransaction( TxType.Type type, @@ -378,20 +355,19 @@ public EthSendTransaction sendKaiaTransaction( BigInteger gas, String from, BigInteger feeRatio) throws IOException { - + BigInteger nonce = getNonce(); KaiaRawTransaction rawTransaction = KaiaRawTransaction.createTransaction( - type, - nonce, - gasPrice, - gas, - from, - feeRatio); + type, + nonce, + gasPrice, + gas, + from, + feeRatio); return signAndSend(rawTransaction); - + } - public EthSendTransaction sendKaiaTransaction( TxType.Type type, BigInteger gasPrice, @@ -400,20 +376,20 @@ public EthSendTransaction sendKaiaTransaction( BigInteger value, String from, BigInteger feeRatio) throws IOException { - + BigInteger nonce = getNonce(); KaiaRawTransaction rawTransaction = KaiaRawTransaction.createTransaction( - type, - nonce, - gasPrice, - gas, - to, - value, - from, - feeRatio); + type, + nonce, + gasPrice, + gas, + to, + value, + from, + feeRatio); return signAndSend(rawTransaction); - + } public EthSendTransaction sendKaiaTransaction( @@ -426,49 +402,46 @@ public EthSendTransaction sendKaiaTransaction( byte[] payload, BigInteger codeFormat, BigInteger feeRatio) throws IOException { - + BigInteger nonce = getNonce(); KaiaRawTransaction rawTransaction = KaiaRawTransaction.createTransaction( - type, - nonce, - gasPrice, - gas, - to, - value, - from, - payload, - codeFormat, - feeRatio); - + type, + nonce, + gasPrice, + gas, + to, + value, + from, + payload, + codeFormat, + feeRatio); return signAndSend(rawTransaction); } - + public EthSendTransaction sendKaiaTransaction( TxType.Type type, BigInteger gasPrice, BigInteger gas, String from, byte[] payload) throws IOException { - + BigInteger nonce = getNonce(); KaiaRawTransaction rawTransaction = KaiaRawTransaction.createTransaction( - type, - nonce, - gasPrice, - gas, - from, - payload); - - return signAndSend(rawTransaction); - + type, + nonce, + gasPrice, + gas, + from, + payload); + return signAndSend(rawTransaction); } - + public EthSendTransaction sendKaiaTransaction( TxType.Type type, BigInteger gasPrice, @@ -476,17 +449,17 @@ public EthSendTransaction sendKaiaTransaction( String from, byte[] payload, BigInteger feeRatio) throws IOException { - + BigInteger nonce = getNonce(); KaiaRawTransaction rawTransaction = KaiaRawTransaction.createTransaction( - type, - nonce, - gasPrice, - gas, - from, - payload, - feeRatio); + type, + nonce, + gasPrice, + gas, + from, + payload, + feeRatio); return signAndSend(rawTransaction); } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/utils/AccountKeyPublicUtils.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/utils/AccountKeyPublicUtils.java index 2eaa36afc..931bb075c 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/utils/AccountKeyPublicUtils.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/utils/AccountKeyPublicUtils.java @@ -14,7 +14,7 @@ public class AccountKeyPublicUtils { public static final X9ECParameters CURVE_PARAMS = CustomNamedCurves.getByName("secp256k1"); static final ECDomainParameters CURVE = new ECDomainParameters( CURVE_PARAMS.getCurve(), CURVE_PARAMS.getG(), CURVE_PARAMS.getN(), CURVE_PARAMS.getH()); - + public static String toCompressedPublicKey(BigInteger publicKey) { String hexStringPublicKey = Numeric.toHexStringNoPrefixZeroPadded(publicKey, 128); String publicKeyX = hexStringPublicKey.substring(0, 64); @@ -27,11 +27,10 @@ public static AccountKeyPublic decompressKey(String compressedPublicKey) { BigInteger xBN = Numeric.toBigInt(compressedPublicKey.substring(2)); X9IntegerConverter x9 = new X9IntegerConverter(); byte[] compEnc = x9.integerToBytes(xBN, 1 + x9.getByteLength(CURVE.getCurve())); - compEnc[0] = (byte)(yBit ? 0x03 : 0x02); + compEnc[0] = (byte) (yBit ? 0x03 : 0x02); ECPoint ecPoint = CURVE.getCurve().decodePoint(compEnc); return AccountKeyPublic.create( Numeric.toHexStringWithPrefixZeroPadded(ecPoint.getAffineXCoord().toBigInteger(), 64), - Numeric.toHexStringWithPrefixZeroPadded(ecPoint.getAffineYCoord().toBigInteger(), 64) - ); + Numeric.toHexStringWithPrefixZeroPadded(ecPoint.getAffineYCoord().toBigInteger(), 64)); } } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/utils/KaiaConvert.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/utils/KaiaConvert.java index 91dae4d9e..779e59b2e 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/utils/KaiaConvert.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/utils/KaiaConvert.java @@ -3,18 +3,22 @@ import java.math.BigDecimal; public class KaiaConvert { - private KaiaConvert() { } + private KaiaConvert() { + } // Kaia units public static BigDecimal fromPeb(String number, Unit unit) { return fromPeb(new BigDecimal(number), unit); } + public static BigDecimal fromPeb(BigDecimal number, Unit unit) { return number.divide(unit.getpebFactor()); } + public static BigDecimal toPeb(String number, Unit unit) { return toPeb(new BigDecimal(number), unit); } + public static BigDecimal toPeb(BigDecimal number, Unit unit) { return number.multiply(unit.getpebFactor()); } @@ -23,12 +27,15 @@ public static BigDecimal toPeb(BigDecimal number, Unit unit) { public static BigDecimal fromKei(String number, Unit unit) { return fromKei(new BigDecimal(number), unit); } + public static BigDecimal fromKei(BigDecimal number, Unit unit) { return number.divide(unit.getpebFactor()); } + public static BigDecimal toKei(String number, Unit unit) { return toKei(new BigDecimal(number), unit); } + public static BigDecimal toKei(BigDecimal number, Unit unit) { return number.multiply(unit.getpebFactor()); } diff --git a/web3j-ext/web3j-ext/src/main/java/org/web3j/utils/KaiaTransactionUtils.java b/web3j-ext/web3j-ext/src/main/java/org/web3j/utils/KaiaTransactionUtils.java index e45bdc88b..296b05767 100644 --- a/web3j-ext/web3j-ext/src/main/java/org/web3j/utils/KaiaTransactionUtils.java +++ b/web3j-ext/web3j-ext/src/main/java/org/web3j/utils/KaiaTransactionUtils.java @@ -5,7 +5,7 @@ import org.web3j.crypto.transaction.type.TxType; public class KaiaTransactionUtils { - + public static TxType.Type getType(byte[] rawTransaction) { return TxType.Type.findByValue(rawTransaction[0]); }