From 5e4730d55c87d50f3e20b5a2b7a937d4a7393b0f Mon Sep 17 00:00:00 2001 From: MaximFischuk Date: Thu, 17 Nov 2022 16:45:14 +0200 Subject: [PATCH] Fix deploy contract transactions. Update integration tests --- .../zksync/methods/request/Transaction.java | 16 +- .../java/io/zksync/transaction/fee/Fee.java | 7 + .../manager/ZkSyncTransactionManager.java | 2 +- .../io/zksync/utils/ContractDeployer.java | 44 +- .../zksync/abi/ZkTransactionEncoderTest.java | 2 +- .../io/zksync/helper/CounterContract.java | 2 +- src/test/java/io/zksync/helper/Import.java | 4 +- .../integration/BaseIntegrationEnv.java | 74 ++- .../IntegrationZkSyncWeb3RpcTest.java | 508 ++++++++++-------- .../io/zksync/protocol/ZkSyncRequestTest.java | 4 +- .../io/zksync/utils/ContractDeployerTest.java | 4 +- .../java/io/zksync/utils/MessengerTest.java | 4 + .../resources/constructorContractBinary.hex | 2 +- 13 files changed, 388 insertions(+), 285 deletions(-) diff --git a/src/main/java/io/zksync/methods/request/Transaction.java b/src/main/java/io/zksync/methods/request/Transaction.java index c9237f3..b4654e7 100644 --- a/src/main/java/io/zksync/methods/request/Transaction.java +++ b/src/main/java/io/zksync/methods/request/Transaction.java @@ -49,6 +49,17 @@ public Transaction(String from, String to, BigInteger gas, BigInteger gasPrice, this.transactionType = (long) Transaction712.EIP_712_TX_TYPE; } + public static Transaction createEtherTransaction( + String from, + BigInteger ergsPrice, + BigInteger ergsLimit, + String to, + BigInteger value) { + + Eip712Meta meta = new Eip712Meta(BigInteger.valueOf(160000L), null, null, null); + return new Transaction(from, to, ergsPrice, ergsLimit, value, "0x", meta); + } + public static Transaction create2ContractTransaction( String from, BigInteger ergsPrice, @@ -295,11 +306,6 @@ public static Transaction createFunctionCallTransaction( return new Transaction(from, to, ergsPrice, ergsLimit, value, data, meta); } - public static org.web3j.protocol.core.methods.request.Transaction createEthCallTransaction(String from, String to, String data) { - - return org.web3j.protocol.core.methods.request.Transaction.createEthCallTransaction(from, to, data); - } - public String getFrom() { return from; } diff --git a/src/main/java/io/zksync/transaction/fee/Fee.java b/src/main/java/io/zksync/transaction/fee/Fee.java index c43bef3..771f558 100644 --- a/src/main/java/io/zksync/transaction/fee/Fee.java +++ b/src/main/java/io/zksync/transaction/fee/Fee.java @@ -34,6 +34,13 @@ public Fee() { this.ergsPerPubdataLimit = Uint256.DEFAULT; } + public Fee(BigInteger ergsLimit, BigInteger maxFeePerErg, BigInteger maxPriorityFeePerErg, BigInteger ergsPerPubdataLimit) { + this.ergsLimit = new Uint256(ergsLimit); + this.maxFeePerErg = new Uint256(maxFeePerErg); + this.maxPriorityFeePerErg = new Uint256(maxPriorityFeePerErg); + this.ergsPerPubdataLimit = new Uint256(ergsPerPubdataLimit); + } + public BigInteger getErgsLimitNumber() { return ergsLimit.getValue(); } diff --git a/src/main/java/io/zksync/transaction/manager/ZkSyncTransactionManager.java b/src/main/java/io/zksync/transaction/manager/ZkSyncTransactionManager.java index 5ec952c..887f68d 100644 --- a/src/main/java/io/zksync/transaction/manager/ZkSyncTransactionManager.java +++ b/src/main/java/io/zksync/transaction/manager/ZkSyncTransactionManager.java @@ -102,7 +102,7 @@ public EthSendTransaction sendEIP1559Transaction(long chainId, BigInteger maxPri public String sendCall(String to, String data, DefaultBlockParameter defaultBlockParameter) throws IOException { EthCall ethCall = zkSync.ethCall( - Transaction.createEthCallTransaction(getFromAddress(), to, data), + org.web3j.protocol.core.methods.request.Transaction.createEthCallTransaction(getFromAddress(), to, data), defaultBlockParameter) .send(); diff --git a/src/main/java/io/zksync/utils/ContractDeployer.java b/src/main/java/io/zksync/utils/ContractDeployer.java index cd2d2d5..3192170 100644 --- a/src/main/java/io/zksync/utils/ContractDeployer.java +++ b/src/main/java/io/zksync/utils/ContractDeployer.java @@ -110,14 +110,20 @@ public static Address extractContractAddress(TransactionReceipt receipt) { public static byte[] hashBytecode(byte[] bytecode) { byte[] bytecodeHash = Hash.sha256(bytecode); + if (bytecode.length % 32 != 0) { + throw new IllegalArgumentException("The bytecode length in bytes must be divisible by 32"); + } + BigInteger length = BigInteger.valueOf(bytecode.length / 32); if (length.compareTo(MAX_BYTECODE_SIZE) > 0) { throw new IllegalArgumentException("Bytecode length must be less than 2^16 bytes"); } + byte[] codeHashVersion = new byte[] { 1, 0 }; byte[] bytecodeLength = Numeric.toBytesPadded(length, 2); - System.arraycopy(bytecodeLength, 0, bytecodeHash, 0, bytecodeLength.length); + System.arraycopy(codeHashVersion, 0, bytecodeHash, 0, codeHashVersion.length); + System.arraycopy(bytecodeLength, 0, bytecodeHash, 2, bytecodeLength.length); return bytecodeHash; } @@ -157,7 +163,7 @@ public static Function encodeCreate2(byte[] bytecode, byte[] calldata, byte[] sa return new Function( "create2", - Arrays.asList(new Bytes32(salt), new Bytes32(bytecodeHash), new Uint256(0), new DynamicBytes(calldata)), + Arrays.asList(new Bytes32(salt), new Bytes32(bytecodeHash), new DynamicBytes(calldata)), Collections.emptyList() ); } @@ -169,7 +175,7 @@ public static Function encodeCreate2(byte[] bytecode, byte[] calldata, byte[] sa * @return Encoded contract function */ public static Function encodeCreate(byte[] bytecode) { - return encodeCreate(bytecode, new byte[] {}, new byte[32]); + return encodeCreate(bytecode, new byte[] {}); } /** @@ -180,23 +186,11 @@ public static Function encodeCreate(byte[] bytecode) { * @return Encoded contract function */ public static Function encodeCreate(byte[] bytecode, byte[] calldata) { - return encodeCreate(bytecode, calldata, new byte[32]); - } - - /** - * Encode `create` deployment function of default factory contract - * - * @param bytecode Compiled bytecode of the contract - * @param calldata Encoded constructor parameters - * @param salt 32 bytes salt - * @return Encoded contract function - */ - public static Function encodeCreate(byte[] bytecode, byte[] calldata, byte[] salt) { byte[] bytecodeHash = hashBytecode(bytecode); return new Function( "create", - Arrays.asList(new Bytes32(new byte[32]), new Bytes32(bytecodeHash), new Uint256(0), new DynamicBytes(calldata)), + Arrays.asList(new Bytes32(new byte[32]), new Bytes32(bytecodeHash), new DynamicBytes(calldata)), Collections.emptyList() ); } @@ -236,7 +230,7 @@ public static Function encodeCreate2Account(byte[] bytecode, byte[] calldata, by return new Function( "create2Account", - Arrays.asList(new Bytes32(salt), new Bytes32(bytecodeHash), new Uint256(0), new DynamicBytes(calldata)), + Arrays.asList(new Bytes32(salt), new Bytes32(bytecodeHash), new DynamicBytes(calldata)), Collections.emptyList() ); } @@ -248,7 +242,7 @@ public static Function encodeCreate2Account(byte[] bytecode, byte[] calldata, by * @return Encoded contract function */ public static Function encodeCreateAccount(byte[] bytecode) { - return encodeCreateAccount(bytecode, new byte[] {}, new byte[32]); + return encodeCreateAccount(bytecode, new byte[] {}); } /** @@ -259,23 +253,11 @@ public static Function encodeCreateAccount(byte[] bytecode) { * @return Encoded contract function */ public static Function encodeCreateAccount(byte[] bytecode, byte[] calldata) { - return encodeCreateAccount(bytecode, calldata, new byte[32]); - } - - /** - * Encode `create` deployment custom account function of default factory contract (see EIP-4337) - * - * @param bytecode Compiled bytecode of the Custom Account contract - * @param calldata Encoded constructor parameters - * @param salt 32 bytes salt - * @return Encoded contract function - */ - public static Function encodeCreateAccount(byte[] bytecode, byte[] calldata, byte[] salt) { byte[] bytecodeHash = hashBytecode(bytecode); return new Function( "createAccount", - Arrays.asList(new Bytes32(new byte[32]), new Bytes32(bytecodeHash), new Uint256(0), new DynamicBytes(calldata)), + Arrays.asList(new Bytes32(new byte[32]), new Bytes32(bytecodeHash), new DynamicBytes(calldata)), Collections.emptyList() ); } diff --git a/src/test/java/io/zksync/abi/ZkTransactionEncoderTest.java b/src/test/java/io/zksync/abi/ZkTransactionEncoderTest.java index 9ffdd8f..d22db5c 100644 --- a/src/test/java/io/zksync/abi/ZkTransactionEncoderTest.java +++ b/src/test/java/io/zksync/abi/ZkTransactionEncoderTest.java @@ -96,7 +96,7 @@ public void testEncodeDeploy() { ) ); - String expected = "0x71f907c6802b2b2a94000000000000000000000000000000000000800680b8a41415dae2000000000000000000000000000000000000000000000000000000000000000000379c09b5568d43b0ac6533a2672ee836815530b412f082f0b2e69915aa50fc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000082010e808082010e947e5f4552091a69125d5dfcb7b8c2659029395bdf80f906e3b906e00000002b04000041000000000141016f0000002c0400004100000000001403760000002d010000410000000000210376000000000130004c000000090000613d00a5000a0000034f00a5001f0000034f0000008001000039000000400200003900000000001203760000000001000357000000000110004c0000001d0000c13d0000002d010000410000000001010375000000000110004c000000180000c13d00000080010000390000000002000019000000000300001900a500960000034f0000002001000039000000000010037600000000000103760000002e01000041000000a6000103700000000001000019000000a70001037200010000000000020000008006000039000000400500003900000000006503760000002d010000410000000001010375000000040110008c0000005a0000413d0000002c01000041000000000101037500000000010103770000002f02000041000000000121016f000000300210009c000000440000c13d0000000001000357000000000110004c0000005c0000c13d0000002d010000410000000001010375000000040110008a000000010200008a0000003203000041000000000221004b00000000020000190000000002032019000000000131016f000000000431013f000000320110009c00000000010000190000000001034019000000320340009c000000000102c019000000000110004c0000005e0000c13d0000000001000019000000a700010372000000310110009c0000005a0000c13d0000000001000357000000000110004c000000650000c13d0000002d010000410000000001010375000000040110008a00000032020000410000001f0310008c00000000030000190000000003022019000000000121016f000000000410004c0000000002008019000000320110009c00000000010300190000000001026019000000000110004c000000670000c13d0000000001000019000000a7000103720000000001000019000000a7000103720000000001000019000000a7000103720000000001000019000100000006001d00a5008b0000034f000000010200002900000000001203760000003401000041000000a6000103700000000001000019000000a7000103720000002c01000041000000000101037500000004011000390000000001010377000100000005001d00a500720000034f000000010100002900000000010103750000003302000041000000000121016f000000a6000103700002000000000002000000010200008a000100000001001d000000000121013f000200000001001d000000000100001900a5008b0000034f0000000202000029000000000221004b000000820000213d00000001020000290000000001210019000000000200001900a500890000034f0000000200000005000000000001036f000000350100004100000000001003760000001101000039000000040200003900000000001203760000003601000041000000a700010372000000000012035b000000000001036f0000000001010359000000000001036f000000000401037500000000043401cf000000000434022f0000010003300089000000000232022f00000000023201cf000000000242019f0000000000210376000000000001036f0000000504300270000000000540004c0000009e0000613d00000000002103760000002001100039000000010440008a000000000540004c000000990000c13d0000001f0330018f000000000430004c000000a40000613d000000030330021000a5008d0000034f000000000001036f000000000001036f000000a500000374000000a600010370000000a700010372000000000000e001000000000000e001000000000000e001000000000000e0010000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000000ffffe00000000000000000000000000000000000000000000000000000000000ffffc00000000000000000000000000000000000000000000000400000000000000000ffffffff000000000000000000000000000000000000000000000000000000006d4ce63c000000000000000000000000000000000000000000000000000000007cf5dab0000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffff00000000000000000000000000000000000000000000002000000000000000804e487b7100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024000000000000000080c0"; + String expected = "0x71f90ae6802b2b2a94000000000000000000000000000000000000800680b8843cda33510000000000000000000000000000000000000000000000000000000000000000010000517112c421df08d7b49e4dc1312f4ee62268ee4f5683b11d9e2d33525a0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000082010e808082010e947e5f4552091a69125d5dfcb7b8c2659029395bdf80f90a23b90a20000200000000000200010000000103550000006001100270000000410010019d000000010120018f000000000110004c000000080000c13d00fd00180000040f00fd00090000040f0000008001000039000000400200003900000000001204350000000001000416000000000110004c000000160000c13d000000200100003900000100020000390000000000120439000001200100003900000000000104390000004201000041000000fe0001042e0000000001000019000000ff0001043000040000000000020000000001000410000080020210008c000000330000613d0000000002000411000080010220008c000000330000613d0000004302000041000000000020043900000004020000390000000000120439000000440100004100008002020000390000000003000415000000040330008a00000020033000c900fd00e00000040f000000ff01000039000000030110024f000000000110004c000000560000613d000000040100035f000000000101043b000000000110004c000000330000c13d0000000001000019000000fe0001042e0000008001000039000000400600003900000000001604350000000001000031000000030210008c000000540000a13d0000000102000367000000000302043b000000e003300270000000450430009c0000006c0000613d000000460230009c000000580000613d000000470230009c000000540000c13d0000000002000416000000000220004c000000800000c13d000000040110008a00000048020000410000001f0310008c000000000300001900000000030220190000004801100197000000000410004c0000000002008019000000480110009c00000000010300190000000001026019000000000110004c0000008e0000c13d0000000001000019000000ff000104300000000001000019000000ff000104300000000001000019000000ff000104300000000002000416000000000220004c0000007e0000c13d000000040110008a000000010200008a0000004803000041000000000221004b000000000200001900000000020320190000004801100197000000480410009c00000000030080190000004801100167000000480110009c00000000010200190000000001036019000000000110004c000000840000c13d0000000001000019000000ff000104300000000003000416000000000330004c000000820000c13d000000040110008a00000048030000410000003f0410008c000000000400001900000000040320190000004801100197000000000510004c0000000003008019000000480110009c00000000010400190000000001036019000000000110004c000000a20000c13d0000000001000019000000ff000104300000000001000019000000ff000104300000000001000019000000ff000104300000000001000019000000ff000104300000000001000019000200000006001d00fd00fb0000040f000000020200002900000000020204330000000000120435000000400120021000000049011001970000004c011001c7000000fe0001042e000200000006001d000000000100001900fd00fb0000040f00000001020003670000000402200370000000000202043b0000000001120019000000000221004b00000000020000190000000102004039000000010220018f000000000220004c000000be0000613d0000004a0100004100000000001004350000001101000039000000040200003900000000001204350000004b01000041000000ff000104300000002401200370000000000201043b000000000120004c0000000001000019000000010100c039000000000112004b000000c50000c13d000100000002001d000200000006001d000000000100001900fd00fb0000040f00000001020003670000000402200370000000000202043b0000000001120019000000000221004b00000000020000190000000102004039000000010220018f000000000220004c000000c70000613d0000004a0100004100000000001004350000001101000039000000040200003900000000001204350000004b01000041000000ff00010430000000000200001900fd00f90000040f0000000201000029000000000101043300000040011002100000004901100197000000fe0001042e0000000001000019000000ff00010430000000000200001900fd00f90000040f000000020100002900000000010104330000000102000029000000000220004c000000d10000c13d00000040011002100000004901100197000000fe0001042e00000044021000390000004d03000041000000000032043500000024021000390000001a0300003900000000003204350000004e020000410000000000210435000000040210003900000020030000390000000000320435000000400110021000000049011001970000004f011001c7000000ff000104300002000000000002000200000003001d0000002003300039000100000003001d000000ef002104230000000203000029000000200230011a000000000201035500000048010000410000000102000029000000200220011a00000000021201bd00000000010300190000000200000005000000000001042d0000000203000029000000200230011a000000000201035500000050010000410000000102000029000000200220011a000000000212018d00000000010300190000000200000005000000000001042d000000000012041b000000000001042d000000000101041a000000000001042d000000fd00000432000000fe0001042e000000ff00010430000000000000000100000000000000010000000000000001000000000000000100000000000000000000000000000000000000000000000000000000ffffffff00000002000000000000000000000000000000400000010000000000000000001806aa1896bbf26568e884a7374b41e002500962caba6a15023a8d90e8508b830200020000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000000000000000000000000436dad6000000000000000000000000000000000000000000000000000000006d4ce63c000000000000000000000000000000000000000000000000000000007cf5dab080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffff00000000000000004e487b71000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002000000000000000000000000054686973206d6574686f6420616c77617973207265766572747300000000000008c379a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000640000000000000000000000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80c0"; assertEquals(expected, Numeric.toHexString(TransactionEncoder.encode(transaction, null))); } diff --git a/src/test/java/io/zksync/helper/CounterContract.java b/src/test/java/io/zksync/helper/CounterContract.java index 127f1ed..c5e85bc 100644 --- a/src/test/java/io/zksync/helper/CounterContract.java +++ b/src/test/java/io/zksync/helper/CounterContract.java @@ -27,7 +27,7 @@ */ @SuppressWarnings("rawtypes") public class CounterContract extends Contract { - public static final String BINARY = "0x0000002b04000041000000000141016f0000002c0400004100000000001403760000002d010000410000000000210376000000000130004c000000090000613d00a5000a0000034f00a5001f0000034f0000008001000039000000400200003900000000001203760000000001000357000000000110004c0000001d0000c13d0000002d010000410000000001010375000000000110004c000000180000c13d00000080010000390000000002000019000000000300001900a500960000034f0000002001000039000000000010037600000000000103760000002e01000041000000a6000103700000000001000019000000a70001037200010000000000020000008006000039000000400500003900000000006503760000002d010000410000000001010375000000040110008c0000005a0000413d0000002c01000041000000000101037500000000010103770000002f02000041000000000121016f000000300210009c000000440000c13d0000000001000357000000000110004c0000005c0000c13d0000002d010000410000000001010375000000040110008a000000010200008a0000003203000041000000000221004b00000000020000190000000002032019000000000131016f000000000431013f000000320110009c00000000010000190000000001034019000000320340009c000000000102c019000000000110004c0000005e0000c13d0000000001000019000000a700010372000000310110009c0000005a0000c13d0000000001000357000000000110004c000000650000c13d0000002d010000410000000001010375000000040110008a00000032020000410000001f0310008c00000000030000190000000003022019000000000121016f000000000410004c0000000002008019000000320110009c00000000010300190000000001026019000000000110004c000000670000c13d0000000001000019000000a7000103720000000001000019000000a7000103720000000001000019000000a7000103720000000001000019000100000006001d00a5008b0000034f000000010200002900000000001203760000003401000041000000a6000103700000000001000019000000a7000103720000002c01000041000000000101037500000004011000390000000001010377000100000005001d00a500720000034f000000010100002900000000010103750000003302000041000000000121016f000000a6000103700002000000000002000000010200008a000100000001001d000000000121013f000200000001001d000000000100001900a5008b0000034f0000000202000029000000000221004b000000820000213d00000001020000290000000001210019000000000200001900a500890000034f0000000200000005000000000001036f000000350100004100000000001003760000001101000039000000040200003900000000001203760000003601000041000000a700010372000000000012035b000000000001036f0000000001010359000000000001036f000000000401037500000000043401cf000000000434022f0000010003300089000000000232022f00000000023201cf000000000242019f0000000000210376000000000001036f0000000504300270000000000540004c0000009e0000613d00000000002103760000002001100039000000010440008a000000000540004c000000990000c13d0000001f0330018f000000000430004c000000a40000613d000000030330021000a5008d0000034f000000000001036f000000000001036f000000a500000374000000a600010370000000a700010372000000000000e001000000000000e001000000000000e001000000000000e0010000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000000ffffe00000000000000000000000000000000000000000000000000000000000ffffc00000000000000000000000000000000000000000000000400000000000000000ffffffff000000000000000000000000000000000000000000000000000000006d4ce63c000000000000000000000000000000000000000000000000000000007cf5dab0000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffff00000000000000000000000000000000000000000000002000000000000000804e487b71000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000240000000000000000"; + public static final String BINARY = "0x000200000000000200010000000103550000006001100270000000410010019d000000010120018f000000000110004c000000080000c13d00fd00180000040f00fd00090000040f0000008001000039000000400200003900000000001204350000000001000416000000000110004c000000160000c13d000000200100003900000100020000390000000000120439000001200100003900000000000104390000004201000041000000fe0001042e0000000001000019000000ff0001043000040000000000020000000001000410000080020210008c000000330000613d0000000002000411000080010220008c000000330000613d0000004302000041000000000020043900000004020000390000000000120439000000440100004100008002020000390000000003000415000000040330008a00000020033000c900fd00e00000040f000000ff01000039000000030110024f000000000110004c000000560000613d000000040100035f000000000101043b000000000110004c000000330000c13d0000000001000019000000fe0001042e0000008001000039000000400600003900000000001604350000000001000031000000030210008c000000540000a13d0000000102000367000000000302043b000000e003300270000000450430009c0000006c0000613d000000460230009c000000580000613d000000470230009c000000540000c13d0000000002000416000000000220004c000000800000c13d000000040110008a00000048020000410000001f0310008c000000000300001900000000030220190000004801100197000000000410004c0000000002008019000000480110009c00000000010300190000000001026019000000000110004c0000008e0000c13d0000000001000019000000ff000104300000000001000019000000ff000104300000000001000019000000ff000104300000000002000416000000000220004c0000007e0000c13d000000040110008a000000010200008a0000004803000041000000000221004b000000000200001900000000020320190000004801100197000000480410009c00000000030080190000004801100167000000480110009c00000000010200190000000001036019000000000110004c000000840000c13d0000000001000019000000ff000104300000000003000416000000000330004c000000820000c13d000000040110008a00000048030000410000003f0410008c000000000400001900000000040320190000004801100197000000000510004c0000000003008019000000480110009c00000000010400190000000001036019000000000110004c000000a20000c13d0000000001000019000000ff000104300000000001000019000000ff000104300000000001000019000000ff000104300000000001000019000000ff000104300000000001000019000200000006001d00fd00fb0000040f000000020200002900000000020204330000000000120435000000400120021000000049011001970000004c011001c7000000fe0001042e000200000006001d000000000100001900fd00fb0000040f00000001020003670000000402200370000000000202043b0000000001120019000000000221004b00000000020000190000000102004039000000010220018f000000000220004c000000be0000613d0000004a0100004100000000001004350000001101000039000000040200003900000000001204350000004b01000041000000ff000104300000002401200370000000000201043b000000000120004c0000000001000019000000010100c039000000000112004b000000c50000c13d000100000002001d000200000006001d000000000100001900fd00fb0000040f00000001020003670000000402200370000000000202043b0000000001120019000000000221004b00000000020000190000000102004039000000010220018f000000000220004c000000c70000613d0000004a0100004100000000001004350000001101000039000000040200003900000000001204350000004b01000041000000ff00010430000000000200001900fd00f90000040f0000000201000029000000000101043300000040011002100000004901100197000000fe0001042e0000000001000019000000ff00010430000000000200001900fd00f90000040f000000020100002900000000010104330000000102000029000000000220004c000000d10000c13d00000040011002100000004901100197000000fe0001042e00000044021000390000004d03000041000000000032043500000024021000390000001a0300003900000000003204350000004e020000410000000000210435000000040210003900000020030000390000000000320435000000400110021000000049011001970000004f011001c7000000ff000104300002000000000002000200000003001d0000002003300039000100000003001d000000ef002104230000000203000029000000200230011a000000000201035500000048010000410000000102000029000000200220011a00000000021201bd00000000010300190000000200000005000000000001042d0000000203000029000000200230011a000000000201035500000050010000410000000102000029000000200220011a000000000212018d00000000010300190000000200000005000000000001042d000000000012041b000000000001042d000000000101041a000000000001042d000000fd00000432000000fe0001042e000000ff00010430000000000000000100000000000000010000000000000001000000000000000100000000000000000000000000000000000000000000000000000000ffffffff00000002000000000000000000000000000000400000010000000000000000001806aa1896bbf26568e884a7374b41e002500962caba6a15023a8d90e8508b830200020000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000000000000000000000000436dad6000000000000000000000000000000000000000000000000000000006d4ce63c000000000000000000000000000000000000000000000000000000007cf5dab080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffff00000000000000004e487b71000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002000000000000000000000000054686973206d6574686f6420616c77617973207265766572747300000000000008c379a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000640000000000000000000000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"; public static final String FUNC_GET = "get"; public static final String FUNC_INCREMENT = "increment"; diff --git a/src/test/java/io/zksync/helper/Import.java b/src/test/java/io/zksync/helper/Import.java index e00b62f..65e70df 100644 --- a/src/test/java/io/zksync/helper/Import.java +++ b/src/test/java/io/zksync/helper/Import.java @@ -26,8 +26,8 @@ */ @SuppressWarnings("rawtypes") public class Import extends Contract { - public static final String BINARY = "0x00000097011001970000009804000041000000000014037600000099010000410000000000210376000000000130004c000000080000613d025500090000034f025500760000034f00040000000000020000008001000039000000400300003900000000001303760000000002000357000000000220004c0000002e0000c13d000200000003001d0000009a02000041000000a40300003900000000002303760000009b02000041000000000021037600000084020000390000000000020376000000c4020000390000000000020376000000e40200003900000000001203760000010401000039000000000001037600008006010000390000009c020000410000000003000356000000040330008a00000020033000c9004901d10000034f0000009d01000041000000040110017f0000000002010378000000000320004c000000300000c13d00000060021000390000004001100039000000000101037800000002050000290000004c0000013d000000000100001900000257000103720000009e01200197000100000001001d00000000010000190255023b0000034f0000009f011001970000000102000029000000000121019f0000000002000019025502390000034f00000099010000410000000001010375000000000110004c000000420000c13d0000000201000029000000000101037500000000020000190000000003000019025502460000034f0000002001000039000000a0020000410000000000120376000000a1010000410000000000010376000000a2010000410000025600010370000000000200001900000000010000190000000205000029000000a3040000410000000000240376000000a40200004100000000001203760000001f0310018f000000000404037500000000020503750000000505100270000000000650004c0000005f0000613d0000000006000019000000050760021000000000087200190000000007740019000000000707037800000000007803760000000106600039000000000756004b000000570000413d000000000530004c0000006f0000613d000000200500008a000000000151016f000000000414001900000000011200190000000303300210000000000501037500000000053501cf000000000535022f00000000040403780000010003300089000000000434022f00000000033401cf000000000353019f00000000003103760000009d01200197000000a40200004100000000020203750000004002200210000000a502200197000000000112019f000002570001037200060000000000020000000001000350000080020210008c000000930000613d0000000002000351000080010220008c000000930000613d000000a602000041000000a7030000410000000000230376000000a80200004100000000001203760000800201000039000000a9020000410000000003000356000000060330008a00000020033000c9025502050000034f000000ff01000039000000050110024f000000000110004c000000910000613d0000009d01000041000000060110017f0000000001010378000000000110004c000000930000c13d0000000001000019000002560001037000000080060000390000004005000039000000000065037600000099010000410000000001010375000000030110008c000000b80000a13d000000980100004100000000010103750000000001010377000000e001100270000000aa0210009c000000ba0000613d000000ab0110009c000000b80000c13d0000000001000357000000000110004c000000d00000c13d00000099010000410000000001010375000000040110008a000000010200008a000000ac03000041000000000221004b00000000020000190000000002032019000000ac01100197000000ac0410009c0000000003008019000000ac01100167000000ac0110009c00000000010200190000000001036019000000000110004c000000d40000c13d00000000010000190000025700010372000000000100001900000257000103720000000001000357000000000110004c000000d20000c13d00000099010000410000000001010375000000040110008a000000010200008a000000ac03000041000000000221004b00000000020000190000000002032019000000ac01100197000000ac0410009c0000000003008019000000ac01100167000000ac0110009c00000000010200190000000001036019000000000110004c000000e20000c13d0000000001000019000002570001037200000000010000190000025700010372000000000100001900000257000103720000000001000019000200000005001d0255023b0000034f000000020a00002900000000080a0375000000ad02000041000000000028037600000000020003550000009e01100197000000040310008c000000ea0000c13d000000a4010000410000000001010375000001020000013d0000000001000019000200000006001d0255023b0000034f0000009e0110019700000002020000290000000000120376000000b7010000410000025600010370000100000008001d0000009d038001970000006002200210000000ae02200197000000000223019f000000af022001c70000000003000356000000040330008a00000020033000c9019802050000034f000000ff01000039000000030210024f00000004010000290000009d03100197000000a304000041000000000034037600000040011002700000009d01100197000000a4030000410000000000130376000000000220004c000000020a00002900000001080000290000019e0000613d0000001f0210018f000000a30300004100000000040303750000000503100270000000000530004c000001110000613d0000000005000019000000050650021000000000076800190000000006640019000000000606037800000000006703760000000105500039000000000635004b000001090000413d000000200300008a000000000520004c000001210000613d000000000531016f000000000454001900000000055800190000000302200210000000000605037500000000062601cf000000000626022f00000000040403780000010002200089000000000424022f00000000022401cf000000000262019f00000000002503760000001f02100039000000000432016f0000000002840019000000000442004b000000000400001900000001040040390000009d0520009c0000013a0000213d000000010440018f000000000440004c0000013a0000c13d00000000002a0376000000ac04000041000000200510008c00000000050000190000000005044019000000ac06100197000000000760004c000000000400a019000000ac0660009c000000000405c019000000000440004c000001410000613d00000000010000190000025700010372000000b5010000410000000000100376000000410100003900000004020000390000000000120376000000b60100004100000257000103720000000004080375000000b10540009c000001460000413d00000000010000190000025700010372000000000181001900000000058400190000001f04500039000000ac06000041000000000714004b00000000070000190000000007064019000000ac04400197000000ac08100197000000000984004b000000000600a019000000000484013f000000ac0440009c00000000040700190000000004066019000000000440004c000001610000613d0000000004050375000000b10640009c000001630000413d000000b5010000410000000000100376000000410100003900000004020000390000000000120376000000b6010000410000025700010372000000000100001900000257000103720000003f06400039000000000336016f0000000003230019000000b10630009c0000016f0000413d000000b5010000410000000000100376000000410100003900000004020000390000000000120376000000b601000041000002570001037200000000003a0376000000000042037600000020035000390000000005430019000000000115004b000001770000a13d000000000100001900000257000103720000002001200039000000000540004c000001820000613d000000000500001900000000061500190000000007530019000000000707037500000000007603760000002005500039000000000645004b0000017b0000413d0000000003140019000000000003037600000000040a0375000200000004001d000000200300003900000000003403760000000003020375000100000003001d000000200240003900000000003203760000004002400039025501c40000034f00000002010000290000009d0110019700000001020000290000004002200210000000b202200041000000b302200197000000b402200041000000b302200197000000000112019f0000025600010370000000a3010000410000000000010376000000a40100004100000000000103760000000001000019000000020a000029000000b0041001970000001f0310018f000000a302000041000000000502037500000000020a03750000000501100270000000000610004c000001af0000613d0000000006000019000000050760021000000000087200190000000007750019000000000707037800000000007803760000000106600039000000000716004b000001a70000413d000000000130004c000001bd0000613d000000000145001900000000044200190000000303300210000000000504037500000000053501cf000000000535022f00000000010103780000010003300089000000000131022f00000000013101cf000000000151019f00000000001403760000009d01200197000000a40200004100000000020203750000004002200210000000a502200197000000000112019f0000025700010372000000000430004c000001ce0000613d000000000400001900000000052400190000000006140019000000000606037500000000006503760000002004400039000000000534004b000001c70000413d00000000012300190000000000010376000000000001036f0002000000000002000200000003001d0000002003300039000100000003001d000001ea002103630000000205000029000000200250011a000000000201001f0000000106000029000000202160011a000000000126004900000003022002100000010003200089000000200110011a000000010331025f000000000101003100000000042101cf000000000343019f000000000220004c000000000103c019000000200260011a000000ac021001cd00000000010500190000000200000005000000000001036f0000000103000029000000020500002900000000020000190000000102004039000000010220018f000000000220004c000002040000c13d000000200250011a000000000201001f0000000006030019000000202160011a000000000126004900000003022002100000010003200089000000200110011a000000010331025f000000000101003100000000042101cf000000000343019f000000000220004c000000000103c019000000200260011a000000b80210019d00000000010500190000000200000005000000000001036f00000000000103710002000000000002000200000003001d0000002003300039000100000003001d0000021e002103650000000205000029000000200250011a000000000201001f0000000106000029000000202160011a000000000126004900000003022002100000010003200089000000200110011a000000010331025f000000000101003100000000042101cf000000000343019f000000000220004c000000000103c019000000200260011a000000ac021001cd00000000010500190000000200000005000000000001036f0000000103000029000000020500002900000000020000190000000102004039000000010220018f000000000220004c000002380000c13d000000200250011a000000000201001f0000000006030019000000202160011a000000000126004900000003022002100000010003200089000000200110011a000000010331025f000000000101003100000000042101cf000000000343019f000000000220004c000000000103c019000000200260011a000000b80210019d00000000010500190000000200000005000000000001036f0000000000010371000000000012035b000000000001036f0000000001010359000000000001036f000000000401037500000000043401cf000000000434022f0000010003300089000000000232022f00000000023201cf000000000242019f0000000000210376000000000001036f0000000504300270000000000540004c0000024e0000613d00000000002103760000002001100039000000010440008a000000000540004c000002490000c13d0000001f0330018f000000000430004c000002540000613d00000003033002100255023d0000034f000000000001036f000000000001036f000002550000037400000256000103700000025700010372000000000000e001000000000000e001000000000000e001000000000000e0010000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000000ffffe00000000000000000000000000000000000000000000000000000000000ffffc000753d4204365b3c66bf7c886b007d26329e20717ec6435335f6a6a6cb12c993e2e9718a8df58e8e8a2c7f7d47a4341921919036d7ea1e9d26c3559996f155420000000000000000000000000000000000000000000000a40000000000000080000000000000000000000000000000000000000000000000ffffffffffffffff000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000e000200000000000000000000000000000000000000000000000400000000000e000000000000000000000000000000000000000000000000000000000000000ffffa00000000000000000000000000000000000000000000000000000000000ffff8000000000000000000000000000000000ffffffffffffffff00000000000000001806aa1896bbf26568e884a7374b41e002500962caba6a15023a8d90e8508b830000000000000000000000000000000000000000000000000000000000fff8000000000000000000000000000000000000000000000000000000000000fff8040000000000000000000000000000000000000000000000240000000000fff80000000000000000000000000000000000000000000000000000000000c298557800000000000000000000000000000000000000000000000000000000c6261261800000000000000000000000000000000000000000000000000000000000000006fdde030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffff0000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000ffffffffffffffe0000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001f000000000000000000000000000000000000000000000000ffffffffffffffe0000000000000000000000000000000000000000000000000000000000000004000000000000000004e487b7100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002000000000000000807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"; - public static final String FOO_BINARY = "0x0000005d011001970000005e0400004100000000001403760000005f010000410000000000210376000000000130004c000000080000613d017000090000034f0170007b0000034f00040000000000020000008001000039000000400200003900000000001203760000000001000357000000000110004c000000280000c13d0000000001000019017001560000034f000000010210018f00000001011002700000007f0310018f000000000420004c000000000301c0190000001f0130008c00000000010000190000000101002039000000010110018f000000000220004c0000000002000019000000010200c039000000010220018f000000000112004b0000002a0000613d000000670100004100000000001003760000002201000039000000040200003900000000001203760000006801000041000001720001037200000000010000190000017200010372000000200130008c0000004b0000413d000200000003001d0000000000000376000080100100003900000060020000410000000003000356000000040330008a00000020033000c9017001200000034f00000004020000290000006101200197000000ff03000039000000030330024f000000000330004c0000005d0000613d000000000201037800000002010000290000001f0110003900000005011002700000000003120019000000000132004b0000004b0000813d000100000003001d000200000002001d00000000010000190000000202000029017001540000034f000000010300002900000002020000290000000102200039000000000132004b000000420000413d00000063010000410000000002000019017001540000034f0000005f010000410000000001010375000000000110004c000000560000c13d000000800100003900000000020000190000000003000019017001610000034f0000002001000039000000640200004100000000001203760000006501000041000000000001037600000066010000410000017100010370000000400220027000000062032001970000001f0420018f00000061022001970000000505200270000000000650004c0000006c0000613d000000000600001900000005076002100000000008710019000000000808037800000000008703760000000106600039000000000756004b000000650000413d000000000540004c000000790000613d0000000304400210000000000503037500000000054501cf000000000545022f000000000131001900000000010103780000010004400089000000000141022f00000000014101cf000000000151019f00000000001303760000004001200210000001720001037200060000000000020000000001000350000080020210008c000000980000613d0000000002000351000080010220008c000000980000613d00000069020000410000006a0300004100000000002303760000006b02000041000000000012037600008002010000390000006c020000410000000003000356000000060330008a00000020033000c9017001200000034f000000ff01000039000000050110024f000000000110004c000000960000613d0000006101000041000000060110017f0000000001010378000000000110004c000000980000c13d000000000100001900000171000103700000005f010000410000000001010375000000030110008c000000b80000a13d0000005e01000041000000000101037500000000010103770000006d011001970000006e0110009c000000b80000c13d0000000001000357000000000110004c000000ba0000c13d0000005f010000410000000001010375000000040110008a000000010200008a0000006f03000041000000000221004b000000000200001900000000020320190000006f011001970000006f0410009c00000000030080190000006f011001670000006f0110009c00000000010200190000000001036019000000000110004c000000bc0000c13d0000000001000019000001720001037200000000010000190000017200010372000000000100001900000172000103720000000001000019017001560000034f000000010210018f00000001031002700000007f0430018f000000000520004c000000000503001900000000050460190000001f0350008c00000000030000190000000103002039000000010330018f000000000420004c0000000004000019000000010400c039000000010440018f000000000334004b000000d50000613d000000670100004100000000001003760000002201000039000000040200003900000000001203760000006801000041000001720001037200000080040000390000000000540376000000000220004c000000e10000c13d000001000200008a000000000121016f000000a0020000390000000000120376000000000150004c000000c001000039000000a001006039000000f90000013d000000bf01000039000000a0030000390000000000000376000000000250004c000001060000613d000100000004001d00000070030000410000000001000019000200000005001d000400000003001d000300000001001d0000000001030019017001560000034f000000030400002900000004030000290000000205000029000000a002400039000000000012037600000001033000390000002001400039000000000251004b000000ea0000413d000000c00140003900000001040000290000001f01100039000000200200008a000000000321016f000000800230008a000000710220009c000001060000a13d000000670100004100000000001003760000004101000039000000040200003900000000001203760000006801000041000001720001037200000040020000390000000000320376000000200200003900000000002303760000000002040375000000200430003900000000002403760000004003300039000000000420004c000001180000613d00000000040000190000000005430019000000a006400039000000000606037500000000006503760000002004400039000000000524004b000001110000413d000000000323001900000000000303760000006201100197000000400220021000000072022000410000007302200197000000000112019f00000171000103700002000000000002000200000003001d0000002003300039000100000003001d00000139002103650000000205000029000000200250011a000000000201001f0000000106000029000000202160011a000000000126004900000003022002100000010003200089000000200110011a000000010331025f000000000101003100000000042101cf000000000343019f000000000220004c000000000103c019000000200260011a0000006f021001cd00000000010500190000000200000005000000000001036f0000000103000029000000020500002900000000020000190000000102004039000000010220018f000000000220004c000001530000c13d000000200250011a000000000201001f0000000006030019000000202160011a000000000126004900000003022002100000010003200089000000200110011a000000010331025f000000000101003100000000042101cf000000000343019f000000000220004c000000000103c019000000200260011a000000740210019d00000000010500190000000200000005000000000001036f0000000000010371000000000012035b000000000001036f0000000001010359000000000001036f000000000401037500000000043401cf000000000434022f0000010003300089000000000232022f00000000023201cf000000000242019f0000000000210376000000000001036f0000000504300270000000000540004c000001690000613d00000000002103760000002001100039000000010440008a000000000540004c000001640000c13d0000001f0330018f000000000430004c0000016f0000613d0000000303300210017001580000034f000000000001036f000000000001036f000001700000037400000171000103700000017200010372000000000000e0010000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000000ffffe00000000000000000000000000000000000000000000000000000000000ffffc00000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000ffffffffffffffff000000000000000000000000000000000000000000000000ffffffffffffffe0466f6f00000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000e000200000000000000000000000000000000000000000000000400000000000e000004e487b710000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000001806aa1896bbf26568e884a7374b41e002500962caba6a15023a8d90e8508b830000000000000000000000000000000000000000000000000000000000fff8000000000000000000000000000000000000000000000000000000000000fff8040000000000000000000000000000000000000000000000240000000000fff800ffffffff0000000000000000000000000000000000000000000000000000000006fdde03000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563000000000000000000000000000000000000000000000000ffffffffffffff7f00000000000000000000000000000000000000000000005f000000000000000000000000000000000000000000000000ffffffffffffffe000000000000000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"; + public static final String BINARY = "0x0004000000000002000200000001035500000060031002700000007d0030019d0000007d03300197000000000131034f000300000001035500000060011002700001007d0010019d000000010120018f000000000110004c0000000d0000c13d01ed006d0000040f01ed000e0000040f00040000000000020000008001000039000000400300003900000000001304350000000002000416000000000220004c000000410000c13d000100000003001d0000007e02000041000000a40300003900000000002304350000007f020000410000000000210435000000840100003900000000000104350000006002000039000000c401000039000200000002001d0000000000210435000000e4010000390000000000010435000000800100004100008006020000390000000003000415000000040330008a00000020033000c901ed01b70000040f000000040100035f000000ff02000039000000030220024f000000010220008c000000430000c13d000000000301043b000000000230004c000000430000613d0000000001000019000200000003001d01ed01eb0000040f000000020200002900000083022001970000008401100197000000000121019f000000000200001901ed01e90000040f000000200100003900000100020000390000000000120439000001200100003900000000000104390000008501000041000001ee0001042e0000000001000019000001ef000104300000004002100370000000000402043b000000600210037000030000000203550000001f0340018f000100000004001f000000010100002900000000010104330000000504400270000000000540004c000000570000613d000000000500001900000005065002100000000007610019000000000662034f000000000606043b00000000006704350000000105500039000000000645004b0000004f0000413d000000000530004c000000660000613d0000000504400210000000000242034f00000000044100190000000303300210000000000504043300000000053501cf000000000535022f000000000202043b0000010003300089000000000232022f00000000023201cf000000000252019f000000000024043500000040011002100000008101100197000000020200002900000001022001ff0000008202200197000000000112019f000001ef0001043000060000000000020000000001000410000080020210008c000000880000613d0000000002000411000080010220008c000000880000613d0000008602000041000000000020043900000004020000390000000000120439000000870100004100008002020000390000000003000415000000060330008a00000020033000c901ed01d00000040f000000ff01000039000000050110024f000000000110004c000000ab0000613d000000060100035f000000000101043b000000000110004c000000880000c13d0000000001000019000001ee0001042e0000008006000039000000400500003900000000006504350000000001000031000000030210008c000000a90000a13d0000000202000367000000000202043b000000e002200270000000880320009c000000ad0000613d000000890220009c000000a90000c13d0000000002000416000000000220004c000000c10000c13d000000040110008a000000010200008a0000008a03000041000000000221004b000000000200001900000000020320190000008a011001970000008a0410009c00000000030080190000008a011001670000008a0110009c00000000010200190000000001036019000000000110004c000000c50000c13d0000000001000019000001ef000104300000000001000019000001ef000104300000000001000019000001ef000104300000000002000416000000000220004c000000c30000c13d000000040110008a000000010200008a0000008a03000041000000000221004b000000000200001900000000020320190000008a011001970000008a0410009c00000000030080190000008a011001670000008a0110009c00000000010200190000000001036019000000000110004c000000d30000c13d0000000001000019000001ef000104300000000001000019000001ef000104300000000001000019000001ef000104300000000001000019000200000005001d01ed01eb0000040f000000020a00002900000000080a04330000008b02000041000000000028043500000000030004140000008302100197000000040120008c000000db0000c13d00000003020003670000000101000031000000f10000013d0000000001000019000200000006001d01ed01eb0000040f0000008301100197000000020200002900000000001204350000009501000041000001ee0001042e000000c0013002100000008c0110019700000040038002100000008103300197000000000113019f0000008d011001c70000000003000415000000040330008a00000020033000c9000100000008001d01ed01d00000040f0000000108000029000000020a000029000000040200035f000300000002035500000060012002700001007d0010019d0000007d01100197000000ff03000039000000030330024f000000000330004c0000012e0000613d0000001f0310018f0000000504100270000000000540004c000000fe0000613d000000000500001900000005065002100000000007680019000000000662034f000000000606043b00000000006704350000000105500039000000000645004b000000f60000413d000000000530004c0000010d0000613d0000000504400210000000000242034f00000000044800190000000303300210000000000504043300000000053501cf000000000535022f000000000202043b0000010003300089000000000232022f00000000023201cf000000000252019f00000000002404350000001f02100039000000200300008a000000000432016f0000000002840019000000000442004b000000000400001900000001040040390000008e0520009c000001270000213d000000010440018f000000000440004c000001270000c13d00000000002a04350000008a04000041000000200510008c000000000500001900000000050440190000008a06100197000000000760004c000000000400a0190000008a0660009c000000000405c019000000000440004c000001520000613d0000000001000019000001ef00010430000000930100004100000000001004350000004101000039000000040200003900000000001204350000009401000041000001ef000104300000001f0410018f00000000030a04330000000501100270000000000510004c0000013c0000613d000000000500001900000005065002100000000007630019000000000662034f000000000606043b00000000006704350000000105500039000000000615004b000001340000413d000000000540004c0000014b0000613d0000000501100210000000000212034f00000000011300190000000304400210000000000501043300000000054501cf000000000545022f000000000202043b0000010004400089000000000242022f00000000024201cf000000000252019f000000000021043500000040013002100000008101100197000000600200003900000001022001ff0000008202200197000000000112019f000001ef0001043000000000040804330000008f0540009c000001570000413d0000000001000019000001ef00010430000000000181001900000000058400190000001f045000390000008a06000041000000000714004b000000000700001900000000070640190000008a044001970000008a08100197000000000984004b000000000600a019000000000484013f0000008a0440009c00000000040700190000000004066019000000000440004c000001720000613d00000000040504330000008f0640009c000001740000413d000000930100004100000000001004350000004101000039000000040200003900000000001204350000009401000041000001ef000104300000000001000019000001ef000104300000003f06400039000000000336016f00000000032300190000008f0630009c000001800000413d000000930100004100000000001004350000004101000039000000040200003900000000001204350000009401000041000001ef0001043000000000003a0435000000000042043500000020035000390000000005430019000000000115004b000001880000a13d0000000001000019000001ef000104300000002001200039000000000540004c000001930000613d000000000500001900000000061500190000000007530019000000000707043300000000007604350000002005500039000000000645004b0000018c0000413d0000000003140019000000000003043500000000040a0433000200000004001d000000200300003900000000003404350000000003020433000100000003001d00000020024000390000000000320435000000400240003901ed01aa0000040f000000020100002900000040011002100000008101100197000000010200002900000060022002100000009002200041000000910220019700000092022000410000009102200197000000000112019f000001ee0001042e000000000430004c000001b40000613d000000000400001900000000052400190000000006140019000000000606043300000000006504350000002004400039000000000534004b000001ad0000413d00000000012300190000000000010435000000000001042d0002000000000002000200000003001d0000002003300039000100000003001d000001c6002104210000000203000029000000200230011a00000000020103550000008a010000410000000102000029000000200220011a00000000021201bd00000000010300190000000200000005000000000001042d0000000203000029000000200230011a000000000201035500000096010000410000000102000029000000200220011a000000000212018d00000000010300190000000200000005000000000001042d0002000000000002000200000003001d0000002003300039000100000003001d000001df002104230000000203000029000000200230011a00000000020103550000008a010000410000000102000029000000200220011a00000000021201bd00000000010300190000000200000005000000000001042d0000000203000029000000200230011a000000000201035500000096010000410000000102000029000000200220011a000000000212018d00000000010300190000000200000005000000000001042d000000000012041b000000000001042d000000000101041a000000000001042d000001ed00000432000001ee0001042e000001ef00010430000000000000000100000000000000010000000000000001000000000000000100000000000000000000000000000000000000000000000000000000ffffffff01000061ed3851b8c5ecd6c9a112682425918e9bca825b159b17cb55fe7342ff9c4d535bdea7cd8a978f128b93471df48c7dbab89d703809115bdc118c235bfd02000000000000000000000000000000000000840000008000000000000000000000000000000000000000000000000000000000ffffffff000000000000000000000000000000000000000000000000ffffffff000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000002000000000000000000000000000000400000010000000000000000001806aa1896bbf26568e884a7374b41e002500962caba6a15023a8d90e8508b83020002000000000000000000000000000000002400000000000000000000000000000000000000000000000000000000000000000000000000000000c298557800000000000000000000000000000000000000000000000000000000c6261261800000000000000000000000000000000000000000000000000000000000000006fdde030000000000000000000000000000000000000000000000000000000000000000ffffffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffff0000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000001f00000000000000000000000000000000000000000000000000000000ffffffe000000000000000000000000000000000000000000000000000000000000000400000000000000000000000004e487b7100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000000000000000000000000000000000200000008000000000000000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"; + public static final String FOO_BINARY = "0x0002000000000002000100000001035500000060011002700000004e0010019d000000010120018f000000000110004c000000080000c13d013100720000040f013100090000040f00040000000000020000008001000039000000400200003900000000001204350000000001000416000000000110004c000000280000c13d00000000010000190131012f0000040f000000010210018f00000001011002700000007f0310018f000000000420004c000000000301c0190000001f0130008c00000000010000190000000101002039000000010110018f000000000220004c0000000002000019000000010200c039000000010220018f000000000112004b0000002a0000613d000000540100004100000000001004350000002201000039000000040200003900000000001204350000005501000041000001330001043000000000010000190000013300010430000000200130008c0000004a0000413d000200000003001d00000000000004350000004f0100004100008010020000390000000003000415000000040330008a00000020033000c9013101140000040f000000040100035f000000ff02000039000000030220024f000000000220004c000000540000613d000000000201043b00000002010000290000001f0110003900000005011002700000000003120019000000000132004b0000004a0000813d000100000003001d000200000002001d000000000100001900000002020000290131012d0000040f000000010300002900000002020000290000000102200039000000000132004b000000410000413d000000520100004100000000020000190131012d0000040f000000200100003900000100020000390000000000120439000001200100003900000000000104390000005301000041000001320001042e00000060021002700000001f0220018f00000065031002700000005003300197000000000430004c000000620000613d00000000040000190000000505400210000000000651034f000000000606043b00000000006504350000000104400039000000000534004b0000005b0000413d000000000420004c000000700000613d00000003022002100000000503300210000000000403043300000000042401cf000000000424022f000000000531034f000000000505043b0000010002200089000000000525022f00000000022501cf000000000242019f00000000002304350000005101100197000001330001043000060000000000020000000001000410000080020210008c0000008d0000613d0000000002000411000080010220008c0000008d0000613d0000005602000041000000000020043900000004020000390000000000120439000000570100004100008002020000390000000003000415000000060330008a00000020033000c9013101140000040f000000ff01000039000000050110024f000000000110004c000000ab0000613d000000060100035f000000000101043b000000000110004c0000008d0000c13d0000000001000019000001320001042e0000000001000031000000030210008c000000a90000a13d0000000102000367000000000202043b0000005802200197000000590220009c000000a90000c13d0000000002000416000000000220004c000000ad0000c13d000000040110008a000000010200008a0000005a03000041000000000221004b000000000200001900000000020320190000005a011001970000005a0410009c00000000030080190000005a011001670000005a0110009c00000000010200190000000001036019000000000110004c000000af0000c13d0000000001000019000001330001043000000000010000190000013300010430000000000100001900000133000104300000000001000019000001330001043000000000010000190131012f0000040f000000010210018f00000001031002700000007f0430018f000000000520004c000000000503001900000000050460190000001f0350008c00000000030000190000000103002039000000010330018f000000000420004c0000000004000019000000010400c039000000010440018f000000000334004b000000c80000613d000000540100004100000000001004350000002201000039000000040200003900000000001204350000005501000041000001330001043000000080040000390000000000540435000000000220004c000000d40000c13d000001000200008a000000000121016f000000a0020000390000000000120435000000000150004c000000c001000039000000a001006039000000ec0000013d000000bf01000039000000a0030000390000000000000435000000000250004c000000f90000613d000100000004001d0000005b030000410000000001000019000200000005001d000400000003001d000300000001001d00000000010300190131012f0000040f000000030400002900000004030000290000000205000029000000a002400039000000000012043500000001033000390000002001400039000000000251004b000000dd0000413d000000c00140003900000001040000290000001f01100039000000200200008a000000000321016f000000800230008a0000005c0220009c000000f90000a13d000000540100004100000000001004350000004101000039000000040200003900000000001204350000005501000041000001330001043000000040020000390000000000320435000000200200003900000000002304350000000002040433000000200430003900000000002404350000004003300039000000000420004c0000010b0000613d00000000040000190000000005430019000000a006400039000000000606043300000000006504350000002004400039000000000524004b000001040000413d0000000003230019000000000003043500000040011002100000005d0110019700000060022002100000005e022000410000005f02200197000000000112019f000001320001042e0002000000000002000200000003001d0000002003300039000100000003001d00000123002104230000000203000029000000200230011a00000000020103550000005a010000410000000102000029000000200220011a00000000021201bd00000000010300190000000200000005000000000001042d0000000203000029000000200230011a000000000201035500000060010000410000000102000029000000200220011a000000000212018d00000000010300190000000200000005000000000001042d000000000012041b000000000001042d000000000101041a000000000001042d0000013100000432000001320001042e0000013300010430000000000000000100000000000000010000000000000001000000000000000100000000000000000000000000000000000000000000000000000000ffffffff020000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000007ffffffffffffff00000000000000000000000000000000ffffffff000000000000000000000000466f6f000000000000000000000000000000000000000000000000000000000600000002000000000000000000000000000000400000010000000000000000004e487b710000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000240000000000000000000000001806aa1896bbf26568e884a7374b41e002500962caba6a15023a8d90e8508b830200020000000000000000000000000000000024000000000000000000000000ffffffff0000000000000000000000000000000000000000000000000000000006fdde03000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563000000000000000000000000000000000000000000000000ffffffffffffff7f0000000000000000000000000000000000000000ffffffe00000000000000000000000000000000000000000000000000000005f00000000000000000000000000000000000000000000000000000000ffffffe00000000000000000000000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"; public static final String FUNC_FOO = "foo"; public static final String FUNC_GETFOONAME = "getFooName"; diff --git a/src/test/java/io/zksync/integration/BaseIntegrationEnv.java b/src/test/java/io/zksync/integration/BaseIntegrationEnv.java index f5be880..cb7574f 100644 --- a/src/test/java/io/zksync/integration/BaseIntegrationEnv.java +++ b/src/test/java/io/zksync/integration/BaseIntegrationEnv.java @@ -1,39 +1,45 @@ package io.zksync.integration; import io.zksync.ZkSyncWallet; +import io.zksync.abi.TransactionEncoder; import io.zksync.crypto.signer.EthSigner; import io.zksync.crypto.signer.PrivateKeyEthSigner; +import io.zksync.methods.request.Eip712Meta; +import io.zksync.methods.response.ZksEstimateFee; import io.zksync.protocol.ZkSync; import io.zksync.protocol.core.Token; import io.zksync.protocol.provider.EthereumProvider; import io.zksync.transaction.fee.DefaultTransactionFeeProvider; +import io.zksync.transaction.fee.Fee; import io.zksync.transaction.fee.ZkTransactionFeeProvider; import io.zksync.transaction.response.ZkSyncTransactionReceiptProcessor; +import io.zksync.transaction.type.Transaction712; +import io.zksync.utils.ContractDeployer; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariables; import org.web3j.crypto.Credentials; import org.web3j.crypto.ECKeyPair; import org.web3j.protocol.Web3j; +import org.web3j.protocol.core.DefaultBlockParameterName; import org.web3j.protocol.core.Response; import org.web3j.protocol.core.methods.request.Transaction; +import org.web3j.protocol.core.methods.response.EthGasPrice; import org.web3j.protocol.core.methods.response.EthSendTransaction; import org.web3j.protocol.core.methods.response.TransactionReceipt; +import org.web3j.protocol.exceptions.TransactionException; import org.web3j.protocol.http.HttpService; import org.web3j.tx.RawTransactionManager; import org.web3j.tx.TransactionManager; import org.web3j.tx.gas.ContractGasProvider; import org.web3j.tx.gas.StaticGasProvider; import org.web3j.utils.Convert; +import org.web3j.utils.Numeric; import java.io.IOException; import java.math.BigInteger; import static org.junit.jupiter.api.Assertions.*; -@EnabledIfEnvironmentVariables({ - @EnabledIfEnvironmentVariable(named = "ZKSYNC2_JAVA_CI_L1_NODE_URL", matches = "http*"), - @EnabledIfEnvironmentVariable(named = "ZKSYNC2_JAVA_CI_L2_NODE_URL", matches = "http*"), -}) public class BaseIntegrationEnv { public static final Token ETH = Token.ETH; @@ -107,20 +113,56 @@ protected void assertResponse(Response response) { assertFalse(response::hasError); } - protected void assertContractDeployResponse(Response response) { - if (response.hasError()) { - System.out.println(response.getError().getMessage()); - System.out.println(response.getError().getData()); - } else { - System.out.println(response.getResult()); - } - - assertFalse(response::hasError); - assertNotNull(response.getResult().getContractAddress()); + protected void assertContractDeployResponse(TransactionReceipt response) { + assertNotNull(response.getContractAddress()); } - protected void assertContractDeployResponse(Response response, String expected) { + protected void assertContractDeployResponse(TransactionReceipt response, String expected) { assertContractDeployResponse(response); - assertEquals(response.getResult().getContractAddress(), expected); + String correctContractAddress = ContractDeployer.extractContractAddress(response).getValue(); + assertEquals(correctContractAddress, expected); + } + + protected TransactionReceipt submitTransaction(io.zksync.methods.request.Transaction estimate) throws IOException, TransactionException { + BigInteger nonce = zksync + .ethGetTransactionCount(credentials.getAddress(), DefaultBlockParameterName.PENDING).send() + .getTransactionCount(); + ZksEstimateFee estimateFee = zksync.zksEstimateFee(estimate).send(); + + EthGasPrice gasPrice = zksync.ethGasPrice().send(); + + assertResponse(estimateFee); + assertResponse(gasPrice); + + Fee fee = estimateFee.getResult(); + + Eip712Meta meta = estimate.getEip712Meta(); + meta.setErgsPerPubdata(fee.getErgsPerPubdataLimitNumber()); + + Transaction712 transaction = new Transaction712( + chainId.longValue(), + nonce, + fee.getErgsLimitNumber(), + estimate.getTo(), + estimate.getValueNumber(), + estimate.getData(), + fee.getMaxPriorityFeePerErgNumber(), + fee.getErgsPriceLimitNumber(), + credentials.getAddress(), + meta + ); + + String signature = signer.getDomain().thenCompose(domain -> signer.signTypedData(domain, transaction)).join(); + byte[] message = TransactionEncoder.encode(transaction, TransactionEncoder.getSignatureData(signature)); + + EthSendTransaction sent = zksync.ethSendRawTransaction(Numeric.toHexString(message)).send(); + + assertResponse(sent); + + TransactionReceipt receipt = processor.waitForTransactionReceipt(sent.getResult()); + + assertTrue(receipt::isStatusOK); + + return receipt; } } diff --git a/src/test/java/io/zksync/integration/IntegrationZkSyncWeb3RpcTest.java b/src/test/java/io/zksync/integration/IntegrationZkSyncWeb3RpcTest.java index 0f2e3e6..dd9e1ea 100755 --- a/src/test/java/io/zksync/integration/IntegrationZkSyncWeb3RpcTest.java +++ b/src/test/java/io/zksync/integration/IntegrationZkSyncWeb3RpcTest.java @@ -1,43 +1,36 @@ package io.zksync.integration; import io.zksync.abi.TransactionEncoder; -import io.zksync.crypto.signer.EthSigner; -import io.zksync.crypto.signer.PrivateKeyEthSigner; import io.zksync.helper.ConstructorContract; import io.zksync.helper.CounterContract; import io.zksync.helper.Import; +import io.zksync.methods.request.Eip712Meta; import io.zksync.methods.response.*; -import io.zksync.protocol.ZkSync; import io.zksync.protocol.core.Token; import io.zksync.protocol.core.ZkBlockParameterName; import io.zksync.protocol.provider.EthereumProvider; -import io.zksync.transaction.fee.DefaultTransactionFeeProvider; -import io.zksync.transaction.fee.ZkTransactionFeeProvider; +import io.zksync.transaction.fee.Fee; import io.zksync.transaction.manager.ZkSyncTransactionManager; -import io.zksync.transaction.response.ZkSyncTransactionReceiptProcessor; import io.zksync.transaction.type.Transaction712; import io.zksync.utils.ContractDeployer; import io.zksync.utils.ZkSyncAddresses; import io.zksync.wrappers.ERC20; import io.zksync.wrappers.IL2Bridge; import io.zksync.wrappers.NonceHolder; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariables; +import org.junit.jupiter.api.function.Executable; import org.web3j.abi.FunctionEncoder; import org.web3j.abi.FunctionReturnDecoder; import org.web3j.abi.datatypes.Address; import org.web3j.abi.datatypes.Function; import org.web3j.abi.datatypes.generated.Uint256; -import org.web3j.crypto.Credentials; -import org.web3j.crypto.ECKeyPair; -import org.web3j.protocol.Web3j; import org.web3j.protocol.core.DefaultBlockParameterName; -import org.web3j.protocol.core.Response; import org.web3j.protocol.core.methods.request.Transaction; import org.web3j.protocol.core.methods.response.*; import org.web3j.protocol.exceptions.TransactionException; -import org.web3j.protocol.http.HttpService; import org.web3j.tx.*; import org.web3j.tx.gas.ContractGasProvider; import org.web3j.tx.gas.DefaultGasProvider; @@ -54,42 +47,11 @@ import static org.junit.jupiter.api.Assertions.*; -@Disabled -public class IntegrationZkSyncWeb3RpcTest { - - private static final String L1_NODE = "http://127.0.0.1:8545"; - private static final String L2_NODE = "http://127.0.0.1:3050"; - - private static final Token ETH = Token.createETH(); - - private static ZkSync zksync; - private static Credentials credentials; - private static EthSigner signer; - - private static ZkSyncTransactionReceiptProcessor processor; - - private static ZkTransactionFeeProvider feeProvider; - - private static String contractAddress; - - private static BigInteger chainId; - - @BeforeAll - public static void setUp() { - zksync = ZkSync.build(new HttpService(L2_NODE)); - credentials = Credentials.create(ECKeyPair.create(BigInteger.ONE)); - - chainId = zksync.ethChainId().sendAsync().join().getChainId(); - - signer = new PrivateKeyEthSigner(credentials, chainId.longValue()); - - processor = new ZkSyncTransactionReceiptProcessor(zksync, 200, 100); - - feeProvider = new DefaultTransactionFeeProvider(zksync, ETH); - - contractAddress = "0xca9e8bfcd17df56ae90c2a5608e8824dfd021067"; - } - +@EnabledIfEnvironmentVariables({ + @EnabledIfEnvironmentVariable(named = "ZKSYNC2_JAVA_CI_L1_NODE_URL", matches = "^https://*"), + @EnabledIfEnvironmentVariable(named = "ZKSYNC2_JAVA_CI_L2_NODE_URL", matches = "^https://*"), +}) +public class IntegrationZkSyncWeb3RpcTest extends BaseIntegrationEnv { @Test public void printChainId() { System.out.println(chainId); @@ -97,12 +59,12 @@ public void printChainId() { } @Test + @Disabled + @Deprecated public void sendTestMoney() { - Web3j web3j = Web3j.build(new HttpService(L1_NODE)); - - String account = web3j.ethAccounts().sendAsync().join().getAccounts().get(0); + String account = l1Web3.ethAccounts().sendAsync().join().getAccounts().get(0); - EthSendTransaction sent = web3j.ethSendTransaction( + EthSendTransaction sent = l1Web3.ethSendTransaction( Transaction.createEtherTransaction(account, null, Convert.toWei("1", Unit.GWEI).toBigInteger(), BigInteger.valueOf(21_000L), credentials.getAddress(), Convert.toWei("1000000", Unit.ETHER).toBigInteger())) .sendAsync().join(); @@ -111,40 +73,47 @@ public void sendTestMoney() { } @Test - public void testGetBalanceOfTokenL1() throws IOException { - Web3j web3j = Web3j.build(new HttpService(L1_NODE)); - EthGetBalance getBalance = web3j + @Disabled + public void testGetBalanceOfNativeL1() throws IOException { + EthGetBalance getBalance = l1Web3 .ethGetBalance(credentials.getAddress(), DefaultBlockParameterName.LATEST) .send(); + assertResponse(getBalance); System.out.printf("%s: %d\n", credentials.getAddress(), Numeric.toBigInt(getBalance.getResult())); + assertTrue(getBalance.getBalance().compareTo(Convert.toWei("0.2", Unit.ETHER).toBigInteger()) >= 0); } @Test + @Disabled public void testDeposit() throws IOException { - Web3j web3j = Web3j.build(new HttpService(L1_NODE)); - BigInteger chainId = web3j.ethChainId().send().getChainId(); - TransactionManager manager = new RawTransactionManager(web3j, credentials, chainId.longValue()); - ContractGasProvider gasProvider = new StaticGasProvider(Convert.toWei("1", Unit.GWEI).toBigInteger(), BigInteger.valueOf(555_000L)); + BigInteger chainId = l1Web3.ethChainId().send().getChainId(); + TransactionManager manager = new RawTransactionManager(l1Web3, credentials, chainId.longValue()); + BigInteger gasPrice = l1Web3.ethGasPrice().send().getGasPrice(); + ContractGasProvider gasProvider = new StaticGasProvider(gasPrice, BigInteger.valueOf(170_000L)); TransactionReceipt receipt = EthereumProvider - .load(zksync, web3j, manager, gasProvider).join() - .deposit(ETH, Convert.toWei("100", Unit.ETHER).toBigInteger(), credentials.getAddress()).join(); + .load(zksync, l1Web3, manager, gasProvider).join() + .deposit(ETH, Convert.toWei("0.1", Unit.ETHER).toBigInteger(), credentials.getAddress()).join(); System.out.println(receipt); } @Test + @Disabled public void testDepositToken() throws IOException { - Token usdc = new Token("0xd35cceead182dcee0f148ebac9447da2c4d449c4", "0x72c4f199cb8784425542583d345e7c00d642e345", "USDC", 6); - Web3j web3j = Web3j.build(new HttpService(L1_NODE)); - BigInteger chainId = web3j.ethChainId().send().getChainId(); - TransactionManager manager = new RawTransactionManager(web3j, credentials, chainId.longValue()); - ContractGasProvider gasProvider = new StaticGasProvider(Convert.toWei("1", Unit.GWEI).toBigInteger(), BigInteger.valueOf(555_000L)); - EthereumProvider provider = EthereumProvider.load(zksync, web3j, manager, gasProvider).join(); - TransactionReceipt approveReceipt = provider.approveDeposits(usdc, Optional.of(usdc.toBigInteger(10000000000L))).join(); + Token token = zksync.zksGetConfirmedTokens(0, (short) 100).send() + .getResult().stream() + .filter(t -> t.getSymbol().equalsIgnoreCase("USDC")) + .findFirst().orElseThrow(IllegalArgumentException::new); + BigInteger chainId = l1Web3.ethChainId().send().getChainId(); + BigInteger gasPrice = l1Web3.ethGasPrice().send().getGasPrice(); + TransactionManager manager = new RawTransactionManager(l1Web3, credentials, chainId.longValue()); + ContractGasProvider gasProvider = new StaticGasProvider(gasPrice, BigInteger.valueOf(200_000L)); + EthereumProvider provider = EthereumProvider.load(zksync, l1Web3, manager, gasProvider).join(); + TransactionReceipt approveReceipt = provider.approveDeposits(token, Optional.of(token.toBigInteger(10000000000L))).join(); System.out.println(approveReceipt); - TransactionReceipt receipt = provider.deposit(usdc, usdc.toBigInteger(10000000000L), credentials.getAddress()).join(); + TransactionReceipt receipt = provider.deposit(token, token.toBigInteger(10000000000L), credentials.getAddress()).join(); System.out.println(receipt); } @@ -179,7 +148,7 @@ public void testGetDeploymentNonce() throws Exception { @Test public void testGetTransactionReceipt() throws IOException { TransactionReceipt receipt = zksync - .ethGetTransactionReceipt("0xc47004cd0ab1d9d7866cfb6d699b73ea5872938f14541661b0f0132e5b8365d1").send() + .ethGetTransactionReceipt("0xea87f073bbb8826edf51abbbc77b5812848c92bfb8a825f82a74586ad3553309").send() .getResult(); System.out.println(receipt); @@ -188,46 +157,51 @@ public void testGetTransactionReceipt() throws IOException { @Test public void testGetTransaction() throws IOException { org.web3j.protocol.core.methods.response.Transaction receipt = zksync - .ethGetTransactionByHash("0xf6b0c2b7f815befda19e895efc26805585ae2002cd7d7f9e782d2c346a108ab6").send() + .ethGetTransactionByHash("0x60c05fffdfca5ffb5884f8dd0a80268f16ef768c71f6e173ed1fb58a50790e29").send() .getResult(); - System.out.println(receipt.getNonce()); + System.out.println(receipt); } @Test public void testTransferNativeToSelf() throws IOException, TransactionException { + final BigInteger value = Convert.toWei(BigDecimal.valueOf(0.01), Unit.ETHER).toBigInteger(); + BigInteger nonce = zksync .ethGetTransactionCount(credentials.getAddress(), ZkBlockParameterName.COMMITTED).send() .getTransactionCount(); - io.zksync.methods.request.Transaction estimate = io.zksync.methods.request.Transaction.createFunctionCallTransaction( - credentials.getAddress(), + io.zksync.methods.request.Transaction estimate = io.zksync.methods.request.Transaction.createEtherTransaction( credentials.getAddress(), BigInteger.ZERO, BigInteger.ZERO, - "0x" + credentials.getAddress(), + value ); - EthEstimateGas estimateGas = zksync.ethEstimateGas(estimate).send(); + ZksEstimateFee estimateFee = zksync.zksEstimateFee(estimate).send(); EthGasPrice gasPrice = zksync.ethGasPrice().send(); - assertResponse(estimateGas); assertResponse(gasPrice); + assertResponse(estimateFee); - System.out.printf("Fee for transaction is: %d\n", estimateGas.getAmountUsed().multiply(gasPrice.getGasPrice())); + Fee fee = estimateFee.getResult(); + + Eip712Meta meta = estimate.getEip712Meta(); + meta.setErgsPerPubdata(fee.getErgsPerPubdataLimitNumber()); Transaction712 transaction = new Transaction712( chainId.longValue(), nonce, - estimateGas.getAmountUsed(), + fee.getErgsLimitNumber(), estimate.getTo(), - Convert.toWei(BigDecimal.valueOf(1), Unit.ETHER).toBigInteger(), + value, estimate.getData(), - BigInteger.valueOf(100000000L), - gasPrice.getGasPrice(), + fee.getMaxPriorityFeePerErgNumber(), + fee.getErgsPriceLimitNumber(), credentials.getAddress(), - estimate.getEip712Meta() + meta ); String signature = signer.getDomain().thenCompose(domain -> signer.signTypedData(domain, transaction)).join(); @@ -242,48 +216,18 @@ public void testTransferNativeToSelf() throws IOException, TransactionException assertTrue(receipt::isStatusOK); } - @Test - public void testTransferNativeToSelfWeb3j_Legacy() throws Exception { - Transfer transfer = new Transfer(zksync, new RawTransactionManager(zksync, credentials, chainId.longValue())); - - TransactionReceipt receipt = transfer.sendFunds( - credentials.getAddress(), - BigDecimal.valueOf(1), - Unit.ETHER, - Convert.toWei("3", Unit.GWEI).toBigInteger(), - BigInteger.valueOf(50_000L) - ).send(); - - assertTrue(receipt::isStatusOK); - } - - @Test - public void testTransferNativeToSelfWeb3j() throws Exception { - Transfer transfer = new Transfer(zksync, new ZkSyncTransactionManager(zksync, signer, feeProvider)); - - TransactionReceipt receipt = transfer.sendFunds( - credentials.getAddress(), - BigDecimal.valueOf(1), - Unit.ETHER, - BigInteger.ZERO, - BigInteger.valueOf(50_000L) - ).send(); - - assertTrue(receipt::isStatusOK); - } - @Test public void testTransferTokenToSelf() throws IOException, TransactionException { BigInteger nonce = zksync .ethGetTransactionCount(credentials.getAddress(), ZkBlockParameterName.COMMITTED).send() .getTransactionCount(); - String tokenAddress = zksync.zksGetConfirmedTokens(0, (short) 100).send() + Token token = zksync.zksGetConfirmedTokens(0, (short) 100).send() .getResult().stream() - .filter(token -> !token.isETH()) - .map(Token::getL2Address) + .filter(t -> t.getSymbol().equalsIgnoreCase("USDC")) .findFirst().orElseThrow(IllegalArgumentException::new); - Function transfer = ERC20.encodeTransfer(credentials.getAddress(), BigInteger.ZERO); + String tokenAddress = token.getL2Address(); + Function transfer = ERC20.encodeTransfer(credentials.getAddress(), token.toBigInteger(10)); String calldata = FunctionEncoder.encode(transfer); io.zksync.methods.request.Transaction estimate = io.zksync.methods.request.Transaction.createFunctionCallTransaction( @@ -294,26 +238,29 @@ public void testTransferTokenToSelf() throws IOException, TransactionException { calldata ); - EthEstimateGas estimateGas = zksync.ethEstimateGas(estimate).send(); + ZksEstimateFee estimateFee = zksync.zksEstimateFee(estimate).send(); EthGasPrice gasPrice = zksync.ethGasPrice().send(); - assertResponse(estimateGas); assertResponse(gasPrice); + assertResponse(estimateFee); - System.out.printf("Fee for transaction is: %d\n", estimateGas.getAmountUsed().multiply(gasPrice.getGasPrice())); + Fee fee = estimateFee.getResult(); + + Eip712Meta meta = estimate.getEip712Meta(); + meta.setErgsPerPubdata(fee.getErgsPerPubdataLimitNumber()); Transaction712 transaction = new Transaction712( chainId.longValue(), nonce, - estimateGas.getAmountUsed(), + fee.getErgsLimitNumber(), estimate.getTo(), estimate.getValueNumber(), estimate.getData(), - BigInteger.valueOf(100000000L), - gasPrice.getGasPrice(), + fee.getMaxPriorityFeePerErgNumber(), + fee.getErgsPriceLimitNumber(), credentials.getAddress(), - estimate.getEip712Meta() + meta ); String signature = signer.getDomain().thenCompose(domain -> signer.signTypedData(domain, transaction)).join(); @@ -330,26 +277,36 @@ public void testTransferTokenToSelf() throws IOException, TransactionException { @Test public void testTransferTokenToSelfWeb3jContract() throws Exception { - ERC20 erc20 = ERC20.load(ETH.getL2Address(), zksync, + Token token = zksync.zksGetConfirmedTokens(0, (short) 100).send() + .getResult().stream() + .filter(t -> t.getSymbol().equalsIgnoreCase("USDC")) + .findFirst().orElseThrow(IllegalArgumentException::new); + + ERC20 erc20 = ERC20.load(token.getL2Address(), zksync, new ZkSyncTransactionManager(zksync, signer, feeProvider), feeProvider); - TransactionReceipt receipt = erc20.transfer("0xe1fab3efd74a77c23b426c302d96372140ff7d0c", BigInteger.valueOf(1L)).send(); + TransactionReceipt receipt = erc20.transfer(credentials.getAddress(), token.toBigInteger(10)).send(); assertTrue(receipt::isStatusOK); } @Test public void testWithdraw() throws IOException, TransactionException { + final Token token = ETH; + final double amount = 0.01; + BigInteger nonce = zksync .ethGetTransactionCount(credentials.getAddress(), ZkBlockParameterName.COMMITTED).send() .getTransactionCount(); + String l2EthBridge = zksync.zksGetBridgeContracts().send().getResult().getL2EthDefaultBridge(); + final Function withdraw = new Function( IL2Bridge.FUNC_WITHDRAW, Arrays.asList(new Address(credentials.getAddress()), - new Address(ETH.getL2Address()), - new Uint256(ETH.toBigInteger(1))), + new Address(token.getL2Address()), + new Uint256(token.toBigInteger(amount))), Collections.emptyList()); String calldata = FunctionEncoder.encode(withdraw); @@ -362,26 +319,29 @@ public void testWithdraw() throws IOException, TransactionException { calldata ); - EthEstimateGas estimateGas = zksync.ethEstimateGas(estimate).send(); + ZksEstimateFee estimateFee = zksync.zksEstimateFee(estimate).send(); EthGasPrice gasPrice = zksync.ethGasPrice().send(); - assertResponse(estimateGas); + assertResponse(estimateFee); assertResponse(gasPrice); - System.out.printf("Fee for transaction is: %d\n", estimateGas.getAmountUsed().multiply(gasPrice.getGasPrice())); + Fee fee = estimateFee.getResult(); + + Eip712Meta meta = estimate.getEip712Meta(); + meta.setErgsPerPubdata(fee.getErgsPerPubdataLimitNumber()); Transaction712 transaction = new Transaction712( chainId.longValue(), nonce, - estimateGas.getAmountUsed(), + fee.getErgsLimitNumber(), estimate.getTo(), estimate.getValueNumber(), estimate.getData(), - BigInteger.valueOf(100000000L), - gasPrice.getGasPrice(), + fee.getMaxPriorityFeePerErgNumber(), + fee.getErgsPriceLimitNumber(), credentials.getAddress(), - estimate.getEip712Meta() + meta ); String signature = signer.getDomain().thenCompose(domain -> signer.signTypedData(domain, transaction)).join(); @@ -397,6 +357,75 @@ public void testWithdraw() throws IOException, TransactionException { } @Test + public void testWithdrawToken() throws IOException, TransactionException { + Token token = zksync.zksGetConfirmedTokens(0, (short) 100).send() + .getResult().stream() + .filter(t -> t.getSymbol().equalsIgnoreCase("USDC")) + .findFirst().orElseThrow(IllegalArgumentException::new); + final double amount = 10; + + BigInteger nonce = zksync + .ethGetTransactionCount(credentials.getAddress(), ZkBlockParameterName.COMMITTED).send() + .getTransactionCount(); + + String l2Erc20Bridge = zksync.zksGetBridgeContracts().send().getResult().getL2Erc20DefaultBridge(); + + final Function withdraw = new Function( + IL2Bridge.FUNC_WITHDRAW, + Arrays.asList(new Address(credentials.getAddress()), + new Address(token.getL2Address()), + new Uint256(token.toBigInteger(amount))), + Collections.emptyList()); + + String calldata = FunctionEncoder.encode(withdraw); + + io.zksync.methods.request.Transaction estimate = io.zksync.methods.request.Transaction.createFunctionCallTransaction( + credentials.getAddress(), + l2Erc20Bridge, + BigInteger.ZERO, + BigInteger.ZERO, + calldata + ); + + ZksEstimateFee estimateFee = zksync.zksEstimateFee(estimate).send(); + + EthGasPrice gasPrice = zksync.ethGasPrice().send(); + + assertResponse(estimateFee); + assertResponse(gasPrice); + + Fee fee = estimateFee.getResult(); + + Eip712Meta meta = estimate.getEip712Meta(); + meta.setErgsPerPubdata(fee.getErgsPerPubdataLimitNumber()); + + Transaction712 transaction = new Transaction712( + chainId.longValue(), + nonce, + fee.getErgsLimitNumber(), + estimate.getTo(), + estimate.getValueNumber(), + estimate.getData(), + fee.getMaxPriorityFeePerErgNumber(), + fee.getErgsPriceLimitNumber(), + credentials.getAddress(), + meta + ); + + String signature = signer.getDomain().thenCompose(domain -> signer.signTypedData(domain, transaction)).join(); + byte[] message = TransactionEncoder.encode(transaction, TransactionEncoder.getSignatureData(signature)); + + EthSendTransaction sent = zksync.ethSendRawTransaction(Numeric.toHexString(message)).send(); + + assertResponse(sent); + + TransactionReceipt receipt = processor.waitForTransactionReceipt(sent.getResult()); + + assertTrue(receipt::isStatusOK); + } + + @Test + @Disabled public void testEstimateGas_Withdraw() throws IOException { String l2EthBridge = zksync.zksGetBridgeContracts().send().getResult().getL2EthDefaultBridge(); final Function withdraw = new Function( @@ -420,6 +449,7 @@ public void testEstimateGas_Withdraw() throws IOException { } @Test + @Disabled public void testEstimateGas_TransferNative() throws IOException { io.zksync.methods.request.Transaction estimate = io.zksync.methods.request.Transaction.createFunctionCallTransaction( credentials.getAddress(), @@ -435,6 +465,7 @@ public void testEstimateGas_TransferNative() throws IOException { } @Test + @Disabled public void testEstimateFee_TransferNative() throws IOException { io.zksync.methods.request.Transaction estimate = io.zksync.methods.request.Transaction.createFunctionCallTransaction( credentials.getAddress(), @@ -451,6 +482,7 @@ public void testEstimateFee_TransferNative() throws IOException { } @Test + @Disabled public void testEstimateGas_Execute() throws IOException { Function transfer = ERC20.encodeTransfer("0xe1fab3efd74a77c23b426c302d96372140ff7d0c", BigInteger.valueOf(1L)); String calldata = FunctionEncoder.encode(transfer); @@ -467,6 +499,7 @@ public void testEstimateGas_Execute() throws IOException { } @Test + @Disabled public void testEstimateGas_DeployContract() throws IOException { EthEstimateGas estimateGas = zksync.ethEstimateGas(io.zksync.methods.request.Transaction.create2ContractTransaction( credentials.getAddress(), @@ -479,6 +512,7 @@ public void testEstimateGas_DeployContract() throws IOException { } @Test + @Disabled public void testEstimateFee_DeployContract() throws IOException { ZksEstimateFee estimateGas = zksync.zksEstimateFee(io.zksync.methods.request.Transaction.create2ContractTransaction( credentials.getAddress(), @@ -491,50 +525,57 @@ public void testEstimateFee_DeployContract() throws IOException { } @Test - public void testDeployWeb3jContract() throws Exception { - TransactionManager transactionManager = new ZkSyncTransactionManager(zksync, signer, feeProvider); - CounterContract contract = CounterContract - .deploy(zksync, transactionManager, feeProvider).send(); - - assertNotNull(contract.getContractAddress()); - System.out.println(contract.getContractAddress()); - - contractAddress = contract.getContractAddress(); + public void testDeployWeb3jContract() { + Executable execute = () -> { + TransactionManager transactionManager = new ZkSyncTransactionManager(zksync, signer, feeProvider); + CounterContract contract = CounterContract + .deploy(zksync, transactionManager, feeProvider).send(); + }; + + assertThrows(RuntimeException.class, execute); } @Test - public void testReadWeb3jContract() throws Exception { - TransactionManager transactionManager = new ZkSyncTransactionManager(zksync, signer, feeProvider); - CounterContract zkCounterContract = CounterContract.load(contractAddress, zksync, transactionManager, feeProvider); - - BigInteger result = zkCounterContract.get().send(); + public void testWeb3jContract() throws Exception { + io.zksync.methods.request.Transaction deploy = io.zksync.methods.request.Transaction.createContractTransaction( + credentials.getAddress(), + BigInteger.ZERO, + BigInteger.ZERO, + CounterContract.BINARY + ); + TransactionReceipt deployed = submitTransaction(deploy); + CounterContract zkCounterContract = CounterContract.load(deployed.getContractAddress(), zksync, new ZkSyncTransactionManager(zksync, signer, feeProvider), feeProvider); - System.out.println(result); + { + BigInteger result = zkCounterContract.get().send(); - assertEquals(BigInteger.ZERO, result); - } + System.out.println(result); - @Test - public void testWriteWeb3jContract() throws Exception { - TransactionManager transactionManager = new ZkSyncTransactionManager(zksync, signer, feeProvider); - CounterContract zkCounterContract = CounterContract.load(contractAddress, zksync, transactionManager, feeProvider); + assertEquals(BigInteger.ZERO, result); + } - TransactionReceipt receipt = zkCounterContract.increment(BigInteger.TEN).send(); + { + TransactionReceipt receipt = zkCounterContract.increment(BigInteger.TEN).send(); - assertTrue(receipt::isStatusOK); + assertTrue(receipt::isStatusOK); - BigInteger result = zkCounterContract.get().send(); + BigInteger result = zkCounterContract.get().send(); - assertEquals(BigInteger.TEN, result); + assertEquals(BigInteger.TEN, result); + } } @Test - public void testDeployContract_Create() throws IOException, TransactionException { + public void testDeployContract_Create() throws Exception { BigInteger nonce = zksync .ethGetTransactionCount(credentials.getAddress(), DefaultBlockParameterName.PENDING).send() - .getTransactionCount(); // TODO: get nonce from holder contract + .getTransactionCount(); - String precomputedAddress = ContractDeployer.computeL2CreateAddress(new Address(credentials.getAddress()), nonce).getValue(); + NonceHolder nonceHolder = NonceHolder.load(ZkSyncAddresses.NONCE_HOLDER_ADDRESS, zksync, new ReadonlyTransactionManager(zksync, credentials.getAddress()), new DefaultGasProvider()); + + BigInteger deploymentNonce = nonceHolder.getDeploymentNonce(credentials.getAddress()).send(); + + String precomputedAddress = ContractDeployer.computeL2CreateAddress(new Address(credentials.getAddress()), deploymentNonce).getValue(); io.zksync.methods.request.Transaction estimate = io.zksync.methods.request.Transaction.createContractTransaction( credentials.getAddress(), @@ -543,25 +584,29 @@ public void testDeployContract_Create() throws IOException, TransactionException CounterContract.BINARY ); - EthEstimateGas estimateGas = zksync.ethEstimateGas(estimate).send(); + ZksEstimateFee estimateFee = zksync.zksEstimateFee(estimate).send(); + EthGasPrice gasPrice = zksync.ethGasPrice().send(); - assertResponse(estimateGas); + assertResponse(estimateFee); assertResponse(gasPrice); - System.out.printf("Fee for transaction is: %d\n", estimateGas.getAmountUsed().multiply(gasPrice.getGasPrice())); + Fee fee = estimateFee.getResult(); + + Eip712Meta meta = estimate.getEip712Meta(); + meta.setErgsPerPubdata(fee.getErgsPerPubdataLimitNumber()); Transaction712 transaction = new Transaction712( chainId.longValue(), nonce, - estimateGas.getAmountUsed(), + fee.getErgsLimitNumber(), estimate.getTo(), estimate.getValueNumber(), estimate.getData(), - BigInteger.valueOf(100000000L), - gasPrice.getGasPrice(), + fee.getMaxPriorityFeePerErgNumber(), + fee.getErgsPriceLimitNumber(), credentials.getAddress(), - estimate.getEip712Meta() + meta ); String signature = signer.getDomain().thenCompose(domain -> signer.signTypedData(domain, transaction)).join(); @@ -575,7 +620,7 @@ public void testDeployContract_Create() throws IOException, TransactionException assertTrue(receipt::isStatusOK); - contractAddress = receipt.getContractAddress(); + String contractAddress = receipt.getContractAddress(); System.out.println("Deployed `CounterContract as: `" + contractAddress); assertEquals(contractAddress.toLowerCase(), precomputedAddress.toLowerCase()); @@ -610,25 +655,29 @@ public void testDeployContractWithConstructor_Create() throws Exception { constructor ); - EthEstimateGas estimateGas = zksync.ethEstimateGas(estimate).send(); + ZksEstimateFee estimateFee = zksync.zksEstimateFee(estimate).send(); + EthGasPrice gasPrice = zksync.ethGasPrice().send(); - assertResponse(estimateGas); + assertResponse(estimateFee); assertResponse(gasPrice); - System.out.printf("Fee for transaction is: %d\n", estimateGas.getAmountUsed().multiply(gasPrice.getGasPrice())); + Fee fee = estimateFee.getResult(); + + Eip712Meta meta = estimate.getEip712Meta(); + meta.setErgsPerPubdata(fee.getErgsPerPubdataLimitNumber()); Transaction712 transaction = new Transaction712( chainId.longValue(), nonce, - estimateGas.getAmountUsed(), + fee.getErgsLimitNumber(), estimate.getTo(), estimate.getValueNumber(), estimate.getData(), - BigInteger.valueOf(100000000L), - gasPrice.getGasPrice(), + fee.getMaxPriorityFeePerErgNumber(), + fee.getErgsPriceLimitNumber(), credentials.getAddress(), - estimate.getEip712Meta() + meta ); String signature = signer.getDomain().thenCompose(domain -> signer.signTypedData(domain, transaction)).join(); @@ -642,9 +691,9 @@ public void testDeployContractWithConstructor_Create() throws Exception { assertTrue(receipt::isStatusOK); - contractAddress = receipt.getContractAddress(); + String contractAddress = receipt.getContractAddress(); System.out.println("Deployed `ConstructorContract as: `" + contractAddress); - assertEquals(contractAddress.toLowerCase(), precomputedAddress.toLowerCase()); + assertContractDeployResponse(receipt, precomputedAddress); Transaction call = Transaction.createEthCallTransaction( credentials.getAddress(), @@ -675,25 +724,29 @@ public void testDeployContract_Create2() throws IOException, TransactionExceptio salt ); - EthEstimateGas estimateGas = zksync.ethEstimateGas(estimate).send(); + ZksEstimateFee estimateFee = zksync.zksEstimateFee(estimate).send(); + EthGasPrice gasPrice = zksync.ethGasPrice().send(); - assertResponse(estimateGas); + assertResponse(estimateFee); assertResponse(gasPrice); - System.out.printf("Fee for transaction is: %d\n", estimateGas.getAmountUsed().multiply(gasPrice.getGasPrice())); + Fee fee = estimateFee.getResult(); + + Eip712Meta meta = estimate.getEip712Meta(); + meta.setErgsPerPubdata(fee.getErgsPerPubdataLimitNumber()); Transaction712 transaction = new Transaction712( chainId.longValue(), nonce, - estimateGas.getAmountUsed(), + fee.getErgsLimitNumber(), estimate.getTo(), estimate.getValueNumber(), estimate.getData(), - BigInteger.valueOf(100000000L), - gasPrice.getGasPrice(), + fee.getMaxPriorityFeePerErgNumber(), + fee.getErgsPriceLimitNumber(), credentials.getAddress(), - estimate.getEip712Meta() + meta ); String signature = signer.getDomain().thenCompose(domain -> signer.signTypedData(domain, transaction)).join(); @@ -707,9 +760,9 @@ public void testDeployContract_Create2() throws IOException, TransactionExceptio assertTrue(receipt::isStatusOK); - contractAddress = receipt.getContractAddress(); + String contractAddress = receipt.getContractAddress(); System.out.println("Deployed `CounterContract as: `" + contractAddress); - assertEquals(contractAddress.toLowerCase(), precomputedAddress.toLowerCase()); + assertContractDeployResponse(receipt, precomputedAddress); Transaction call = Transaction.createEthCallTransaction( credentials.getAddress(), @@ -742,25 +795,29 @@ public void testDeployContractWithDeps_Create() throws Exception { "0x" ); - EthEstimateGas estimateGas = zksync.ethEstimateGas(estimate).send(); + ZksEstimateFee estimateFee = zksync.zksEstimateFee(estimate).send(); + EthGasPrice gasPrice = zksync.ethGasPrice().send(); - assertResponse(estimateGas); + assertResponse(estimateFee); assertResponse(gasPrice); - System.out.printf("Fee for transaction is: %d\n", estimateGas.getAmountUsed().multiply(gasPrice.getGasPrice())); + Fee fee = estimateFee.getResult(); + + Eip712Meta meta = estimate.getEip712Meta(); + meta.setErgsPerPubdata(fee.getErgsPerPubdataLimitNumber()); Transaction712 transaction = new Transaction712( chainId.longValue(), nonce, - estimateGas.getAmountUsed(), + fee.getErgsLimitNumber(), estimate.getTo(), estimate.getValueNumber(), estimate.getData(), - BigInteger.valueOf(100000000L), - gasPrice.getGasPrice(), + fee.getMaxPriorityFeePerErgNumber(), + fee.getErgsPriceLimitNumber(), credentials.getAddress(), - estimate.getEip712Meta() + meta ); String signature = signer.getDomain().thenCompose(domain -> signer.signTypedData(domain, transaction)).join(); @@ -776,7 +833,7 @@ public void testDeployContractWithDeps_Create() throws Exception { String contractAddress = ContractDeployer.extractContractAddress(receipt).getValue(); System.out.println("Deployed `Import as: `" + contractAddress); - assertEquals(contractAddress.toLowerCase(), precomputedAddress.toLowerCase()); + assertContractDeployResponse(receipt, precomputedAddress); Function getFooName = Import.encodeGetFooName(); @@ -813,25 +870,29 @@ public void testDeployContractWithDeps_Create2() throws IOException, Transaction salt ); - EthEstimateGas estimateGas = zksync.ethEstimateGas(estimate).send(); + ZksEstimateFee estimateFee = zksync.zksEstimateFee(estimate).send(); + EthGasPrice gasPrice = zksync.ethGasPrice().send(); - assertResponse(estimateGas); + assertResponse(estimateFee); assertResponse(gasPrice); - System.out.printf("Fee for transaction is: %d\n", estimateGas.getAmountUsed().multiply(gasPrice.getGasPrice())); + Fee fee = estimateFee.getResult(); + + Eip712Meta meta = estimate.getEip712Meta(); + meta.setErgsPerPubdata(fee.getErgsPerPubdataLimitNumber()); Transaction712 transaction = new Transaction712( chainId.longValue(), nonce, - estimateGas.getAmountUsed(), + fee.getErgsLimitNumber(), estimate.getTo(), estimate.getValueNumber(), estimate.getData(), - BigInteger.valueOf(100000000L), - gasPrice.getGasPrice(), + fee.getMaxPriorityFeePerErgNumber(), + fee.getErgsPriceLimitNumber(), credentials.getAddress(), - estimate.getEip712Meta() + meta ); String signature = signer.getDomain().thenCompose(domain -> signer.signTypedData(domain, transaction)).join(); @@ -847,7 +908,7 @@ public void testDeployContractWithDeps_Create2() throws IOException, Transaction String contractAddress = ContractDeployer.extractContractAddress(receipt).getValue(); System.out.println("Deployed `Import as: `" + contractAddress); - assertEquals(contractAddress.toLowerCase(), precomputedAddress.toLowerCase()); + assertContractDeployResponse(receipt, precomputedAddress); Function getFooName = Import.encodeGetFooName(); @@ -866,6 +927,14 @@ public void testDeployContractWithDeps_Create2() throws IOException, Transaction @Test public void testExecuteContract() throws IOException, TransactionException { + io.zksync.methods.request.Transaction deploy = io.zksync.methods.request.Transaction.createContractTransaction( + credentials.getAddress(), + BigInteger.ZERO, + BigInteger.ZERO, + CounterContract.BINARY + ); + TransactionReceipt deployed = submitTransaction(deploy); + String contractAddress = deployed.getContractAddress(); BigInteger nonce = zksync .ethGetTransactionCount(credentials.getAddress(), ZkBlockParameterName.COMMITTED).send() .getTransactionCount(); @@ -889,25 +958,29 @@ public void testExecuteContract() throws IOException, TransactionException { calldata ); - EthEstimateGas estimateGas = zksync.ethEstimateGas(estimate).send(); + ZksEstimateFee estimateFee = zksync.zksEstimateFee(estimate).send(); + EthGasPrice gasPrice = zksync.ethGasPrice().send(); - assertResponse(estimateGas); + assertResponse(estimateFee); assertResponse(gasPrice); - System.out.printf("Fee for transaction is: %d\n", estimateGas.getAmountUsed().multiply(gasPrice.getGasPrice())); + Fee fee = estimateFee.getResult(); + + Eip712Meta meta = estimate.getEip712Meta(); + meta.setErgsPerPubdata(fee.getErgsPerPubdataLimitNumber()); Transaction712 transaction = new Transaction712( chainId.longValue(), nonce, - estimateGas.getAmountUsed(), + fee.getErgsLimitNumber(), estimate.getTo(), estimate.getValueNumber(), estimate.getData(), - BigInteger.valueOf(100000000L), - gasPrice.getGasPrice(), + fee.getMaxPriorityFeePerErgNumber(), + fee.getErgsPriceLimitNumber(), credentials.getAddress(), - estimate.getEip712Meta() + meta ); String signature = signer.getDomain().thenCompose(domain -> signer.signTypedData(domain, transaction)).join(); @@ -983,15 +1056,4 @@ public void testGetMainContract() throws IOException { assertResponse(response); } - private void assertResponse(Response response) { - if (response.hasError()) { - System.out.println(response.getError().getMessage()); - System.out.println(response.getError().getData()); - } else { - System.out.println(response.getResult()); - } - - assertFalse(response::hasError); - } - } diff --git a/src/test/java/io/zksync/protocol/ZkSyncRequestTest.java b/src/test/java/io/zksync/protocol/ZkSyncRequestTest.java index b49cd16..dc75ee2 100644 --- a/src/test/java/io/zksync/protocol/ZkSyncRequestTest.java +++ b/src/test/java/io/zksync/protocol/ZkSyncRequestTest.java @@ -42,7 +42,7 @@ void ethEstimateFee_DeployContract() throws Exception { zkSync.zksEstimateFee(estimate).send(); - verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"zks_estimateFee\",\"params\":[{\"from\":\"0x7e5f4552091a69125d5dfcb7b8c2659029395bdf\",\"to\":\"0x0000000000000000000000000000000000008006\",\"gas\":\"0x0\",\"gasPrice\":\"0x0\",\"data\":\"0x1415dae2000000000000000000000000000000000000000000000000000000000000000000379c09b5568d43b0ac6533a2672ee836815530b412f082f0b2e69915aa50fc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000\",\"transactionType\":\"0x71\",\"eip712Meta\":{\"ergsPerPubdata\":\"0x27100\",\"factoryDeps\":[[0,0,0,43,4,0,0,65,0,0,0,0,1,65,1,111,0,0,0,44,4,0,0,65,0,0,0,0,0,20,3,118,0,0,0,45,1,0,0,65,0,0,0,0,0,33,3,118,0,0,0,0,1,48,0,76,0,0,0,9,0,0,97,61,0,165,0,10,0,0,3,79,0,165,0,31,0,0,3,79,0,0,0,128,1,0,0,57,0,0,0,64,2,0,0,57,0,0,0,0,0,18,3,118,0,0,0,0,1,0,3,87,0,0,0,0,1,16,0,76,0,0,0,29,0,0,193,61,0,0,0,45,1,0,0,65,0,0,0,0,1,1,3,117,0,0,0,0,1,16,0,76,0,0,0,24,0,0,193,61,0,0,0,128,1,0,0,57,0,0,0,0,2,0,0,25,0,0,0,0,3,0,0,25,0,165,0,150,0,0,3,79,0,0,0,32,1,0,0,57,0,0,0,0,0,16,3,118,0,0,0,0,0,1,3,118,0,0,0,46,1,0,0,65,0,0,0,166,0,1,3,112,0,0,0,0,1,0,0,25,0,0,0,167,0,1,3,114,0,1,0,0,0,0,0,2,0,0,0,128,6,0,0,57,0,0,0,64,5,0,0,57,0,0,0,0,0,101,3,118,0,0,0,45,1,0,0,65,0,0,0,0,1,1,3,117,0,0,0,4,1,16,0,140,0,0,0,90,0,0,65,61,0,0,0,44,1,0,0,65,0,0,0,0,1,1,3,117,0,0,0,0,1,1,3,119,0,0,0,47,2,0,0,65,0,0,0,0,1,33,1,111,0,0,0,48,2,16,0,156,0,0,0,68,0,0,193,61,0,0,0,0,1,0,3,87,0,0,0,0,1,16,0,76,0,0,0,92,0,0,193,61,0,0,0,45,1,0,0,65,0,0,0,0,1,1,3,117,0,0,0,4,1,16,0,138,0,0,0,1,2,0,0,138,0,0,0,50,3,0,0,65,0,0,0,0,2,33,0,75,0,0,0,0,2,0,0,25,0,0,0,0,2,3,32,25,0,0,0,0,1,49,1,111,0,0,0,0,4,49,1,63,0,0,0,50,1,16,0,156,0,0,0,0,1,0,0,25,0,0,0,0,1,3,64,25,0,0,0,50,3,64,0,156,0,0,0,0,1,2,192,25,0,0,0,0,1,16,0,76,0,0,0,94,0,0,193,61,0,0,0,0,1,0,0,25,0,0,0,167,0,1,3,114,0,0,0,49,1,16,0,156,0,0,0,90,0,0,193,61,0,0,0,0,1,0,3,87,0,0,0,0,1,16,0,76,0,0,0,101,0,0,193,61,0,0,0,45,1,0,0,65,0,0,0,0,1,1,3,117,0,0,0,4,1,16,0,138,0,0,0,50,2,0,0,65,0,0,0,31,3,16,0,140,0,0,0,0,3,0,0,25,0,0,0,0,3,2,32,25,0,0,0,0,1,33,1,111,0,0,0,0,4,16,0,76,0,0,0,0,2,0,128,25,0,0,0,50,1,16,0,156,0,0,0,0,1,3,0,25,0,0,0,0,1,2,96,25,0,0,0,0,1,16,0,76,0,0,0,103,0,0,193,61,0,0,0,0,1,0,0,25,0,0,0,167,0,1,3,114,0,0,0,0,1,0,0,25,0,0,0,167,0,1,3,114,0,0,0,0,1,0,0,25,0,0,0,167,0,1,3,114,0,0,0,0,1,0,0,25,0,1,0,0,0,6,0,29,0,165,0,139,0,0,3,79,0,0,0,1,2,0,0,41,0,0,0,0,0,18,3,118,0,0,0,52,1,0,0,65,0,0,0,166,0,1,3,112,0,0,0,0,1,0,0,25,0,0,0,167,0,1,3,114,0,0,0,44,1,0,0,65,0,0,0,0,1,1,3,117,0,0,0,4,1,16,0,57,0,0,0,0,1,1,3,119,0,1,0,0,0,5,0,29,0,165,0,114,0,0,3,79,0,0,0,1,1,0,0,41,0,0,0,0,1,1,3,117,0,0,0,51,2,0,0,65,0,0,0,0,1,33,1,111,0,0,0,166,0,1,3,112,0,2,0,0,0,0,0,2,0,0,0,1,2,0,0,138,0,1,0,0,0,1,0,29,0,0,0,0,1,33,1,63,0,2,0,0,0,1,0,29,0,0,0,0,1,0,0,25,0,165,0,139,0,0,3,79,0,0,0,2,2,0,0,41,0,0,0,0,2,33,0,75,0,0,0,130,0,0,33,61,0,0,0,1,2,0,0,41,0,0,0,0,1,33,0,25,0,0,0,0,2,0,0,25,0,165,0,137,0,0,3,79,0,0,0,2,0,0,0,5,0,0,0,0,0,1,3,111,0,0,0,53,1,0,0,65,0,0,0,0,0,16,3,118,0,0,0,17,1,0,0,57,0,0,0,4,2,0,0,57,0,0,0,0,0,18,3,118,0,0,0,54,1,0,0,65,0,0,0,167,0,1,3,114,0,0,0,0,0,18,3,91,0,0,0,0,0,1,3,111,0,0,0,0,1,1,3,89,0,0,0,0,0,1,3,111,0,0,0,0,4,1,3,117,0,0,0,0,4,52,1,207,0,0,0,0,4,52,2,47,0,0,1,0,3,48,0,137,0,0,0,0,2,50,2,47,0,0,0,0,2,50,1,207,0,0,0,0,2,66,1,159,0,0,0,0,0,33,3,118,0,0,0,0,0,1,3,111,0,0,0,5,4,48,2,112,0,0,0,0,5,64,0,76,0,0,0,158,0,0,97,61,0,0,0,0,0,33,3,118,0,0,0,32,1,16,0,57,0,0,0,1,4,64,0,138,0,0,0,0,5,64,0,76,0,0,0,153,0,0,193,61,0,0,0,31,3,48,1,143,0,0,0,0,4,48,0,76,0,0,0,164,0,0,97,61,0,0,0,3,3,48,2,16,0,165,0,141,0,0,3,79,0,0,0,0,0,1,3,111,0,0,0,0,0,1,3,111,0,0,0,165,0,0,3,116,0,0,0,166,0,1,3,112,0,0,0,167,0,1,3,114,0,0,0,0,0,0,224,1,0,0,0,0,0,0,224,1,0,0,0,0,0,0,224,1,0,0,0,0,0,0,224,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,224,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,109,76,230,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,124,245,218,176,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,128,78,72,123,113,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,36,0,0,0,0,0,0,0,0]]}}],\"id\":1}"); + verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"zks_estimateFee\",\"params\":[{\"from\":\"0x7e5f4552091a69125d5dfcb7b8c2659029395bdf\",\"to\":\"0x0000000000000000000000000000000000008006\",\"gas\":\"0x0\",\"gasPrice\":\"0x0\",\"data\":\"0x3cda33510000000000000000000000000000000000000000000000000000000000000000010000517112c421df08d7b49e4dc1312f4ee62268ee4f5683b11d9e2d33525a00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000\",\"transactionType\":\"0x71\",\"eip712Meta\":{\"ergsPerPubdata\":\"0x27100\",\"factoryDeps\":[[0,2,0,0,0,0,0,2,0,1,0,0,0,1,3,85,0,0,0,96,1,16,2,112,0,0,0,65,0,16,1,157,0,0,0,1,1,32,1,143,0,0,0,0,1,16,0,76,0,0,0,8,0,0,193,61,0,253,0,24,0,0,4,15,0,253,0,9,0,0,4,15,0,0,0,128,1,0,0,57,0,0,0,64,2,0,0,57,0,0,0,0,0,18,4,53,0,0,0,0,1,0,4,22,0,0,0,0,1,16,0,76,0,0,0,22,0,0,193,61,0,0,0,32,1,0,0,57,0,0,1,0,2,0,0,57,0,0,0,0,0,18,4,57,0,0,1,32,1,0,0,57,0,0,0,0,0,1,4,57,0,0,0,66,1,0,0,65,0,0,0,254,0,1,4,46,0,0,0,0,1,0,0,25,0,0,0,255,0,1,4,48,0,4,0,0,0,0,0,2,0,0,0,0,1,0,4,16,0,0,128,2,2,16,0,140,0,0,0,51,0,0,97,61,0,0,0,0,2,0,4,17,0,0,128,1,2,32,0,140,0,0,0,51,0,0,97,61,0,0,0,67,2,0,0,65,0,0,0,0,0,32,4,57,0,0,0,4,2,0,0,57,0,0,0,0,0,18,4,57,0,0,0,68,1,0,0,65,0,0,128,2,2,0,0,57,0,0,0,0,3,0,4,21,0,0,0,4,3,48,0,138,0,0,0,32,3,48,0,201,0,253,0,224,0,0,4,15,0,0,0,255,1,0,0,57,0,0,0,3,1,16,2,79,0,0,0,0,1,16,0,76,0,0,0,86,0,0,97,61,0,0,0,4,1,0,3,95,0,0,0,0,1,1,4,59,0,0,0,0,1,16,0,76,0,0,0,51,0,0,193,61,0,0,0,0,1,0,0,25,0,0,0,254,0,1,4,46,0,0,0,128,1,0,0,57,0,0,0,64,6,0,0,57,0,0,0,0,0,22,4,53,0,0,0,0,1,0,0,49,0,0,0,3,2,16,0,140,0,0,0,84,0,0,161,61,0,0,0,1,2,0,3,103,0,0,0,0,3,2,4,59,0,0,0,224,3,48,2,112,0,0,0,69,4,48,0,156,0,0,0,108,0,0,97,61,0,0,0,70,2,48,0,156,0,0,0,88,0,0,97,61,0,0,0,71,2,48,0,156,0,0,0,84,0,0,193,61,0,0,0,0,2,0,4,22,0,0,0,0,2,32,0,76,0,0,0,128,0,0,193,61,0,0,0,4,1,16,0,138,0,0,0,72,2,0,0,65,0,0,0,31,3,16,0,140,0,0,0,0,3,0,0,25,0,0,0,0,3,2,32,25,0,0,0,72,1,16,1,151,0,0,0,0,4,16,0,76,0,0,0,0,2,0,128,25,0,0,0,72,1,16,0,156,0,0,0,0,1,3,0,25,0,0,0,0,1,2,96,25,0,0,0,0,1,16,0,76,0,0,0,142,0,0,193,61,0,0,0,0,1,0,0,25,0,0,0,255,0,1,4,48,0,0,0,0,1,0,0,25,0,0,0,255,0,1,4,48,0,0,0,0,1,0,0,25,0,0,0,255,0,1,4,48,0,0,0,0,2,0,4,22,0,0,0,0,2,32,0,76,0,0,0,126,0,0,193,61,0,0,0,4,1,16,0,138,0,0,0,1,2,0,0,138,0,0,0,72,3,0,0,65,0,0,0,0,2,33,0,75,0,0,0,0,2,0,0,25,0,0,0,0,2,3,32,25,0,0,0,72,1,16,1,151,0,0,0,72,4,16,0,156,0,0,0,0,3,0,128,25,0,0,0,72,1,16,1,103,0,0,0,72,1,16,0,156,0,0,0,0,1,2,0,25,0,0,0,0,1,3,96,25,0,0,0,0,1,16,0,76,0,0,0,132,0,0,193,61,0,0,0,0,1,0,0,25,0,0,0,255,0,1,4,48,0,0,0,0,3,0,4,22,0,0,0,0,3,48,0,76,0,0,0,130,0,0,193,61,0,0,0,4,1,16,0,138,0,0,0,72,3,0,0,65,0,0,0,63,4,16,0,140,0,0,0,0,4,0,0,25,0,0,0,0,4,3,32,25,0,0,0,72,1,16,1,151,0,0,0,0,5,16,0,76,0,0,0,0,3,0,128,25,0,0,0,72,1,16,0,156,0,0,0,0,1,4,0,25,0,0,0,0,1,3,96,25,0,0,0,0,1,16,0,76,0,0,0,162,0,0,193,61,0,0,0,0,1,0,0,25,0,0,0,255,0,1,4,48,0,0,0,0,1,0,0,25,0,0,0,255,0,1,4,48,0,0,0,0,1,0,0,25,0,0,0,255,0,1,4,48,0,0,0,0,1,0,0,25,0,0,0,255,0,1,4,48,0,0,0,0,1,0,0,25,0,2,0,0,0,6,0,29,0,253,0,251,0,0,4,15,0,0,0,2,2,0,0,41,0,0,0,0,2,2,4,51,0,0,0,0,0,18,4,53,0,0,0,64,1,32,2,16,0,0,0,73,1,16,1,151,0,0,0,76,1,16,1,199,0,0,0,254,0,1,4,46,0,2,0,0,0,6,0,29,0,0,0,0,1,0,0,25,0,253,0,251,0,0,4,15,0,0,0,1,2,0,3,103,0,0,0,4,2,32,3,112,0,0,0,0,2,2,4,59,0,0,0,0,1,18,0,25,0,0,0,0,2,33,0,75,0,0,0,0,2,0,0,25,0,0,0,1,2,0,64,57,0,0,0,1,2,32,1,143,0,0,0,0,2,32,0,76,0,0,0,190,0,0,97,61,0,0,0,74,1,0,0,65,0,0,0,0,0,16,4,53,0,0,0,17,1,0,0,57,0,0,0,4,2,0,0,57,0,0,0,0,0,18,4,53,0,0,0,75,1,0,0,65,0,0,0,255,0,1,4,48,0,0,0,36,1,32,3,112,0,0,0,0,2,1,4,59,0,0,0,0,1,32,0,76,0,0,0,0,1,0,0,25,0,0,0,1,1,0,192,57,0,0,0,0,1,18,0,75,0,0,0,197,0,0,193,61,0,1,0,0,0,2,0,29,0,2,0,0,0,6,0,29,0,0,0,0,1,0,0,25,0,253,0,251,0,0,4,15,0,0,0,1,2,0,3,103,0,0,0,4,2,32,3,112,0,0,0,0,2,2,4,59,0,0,0,0,1,18,0,25,0,0,0,0,2,33,0,75,0,0,0,0,2,0,0,25,0,0,0,1,2,0,64,57,0,0,0,1,2,32,1,143,0,0,0,0,2,32,0,76,0,0,0,199,0,0,97,61,0,0,0,74,1,0,0,65,0,0,0,0,0,16,4,53,0,0,0,17,1,0,0,57,0,0,0,4,2,0,0,57,0,0,0,0,0,18,4,53,0,0,0,75,1,0,0,65,0,0,0,255,0,1,4,48,0,0,0,0,2,0,0,25,0,253,0,249,0,0,4,15,0,0,0,2,1,0,0,41,0,0,0,0,1,1,4,51,0,0,0,64,1,16,2,16,0,0,0,73,1,16,1,151,0,0,0,254,0,1,4,46,0,0,0,0,1,0,0,25,0,0,0,255,0,1,4,48,0,0,0,0,2,0,0,25,0,253,0,249,0,0,4,15,0,0,0,2,1,0,0,41,0,0,0,0,1,1,4,51,0,0,0,1,2,0,0,41,0,0,0,0,2,32,0,76,0,0,0,209,0,0,193,61,0,0,0,64,1,16,2,16,0,0,0,73,1,16,1,151,0,0,0,254,0,1,4,46,0,0,0,68,2,16,0,57,0,0,0,77,3,0,0,65,0,0,0,0,0,50,4,53,0,0,0,36,2,16,0,57,0,0,0,26,3,0,0,57,0,0,0,0,0,50,4,53,0,0,0,78,2,0,0,65,0,0,0,0,0,33,4,53,0,0,0,4,2,16,0,57,0,0,0,32,3,0,0,57,0,0,0,0,0,50,4,53,0,0,0,64,1,16,2,16,0,0,0,73,1,16,1,151,0,0,0,79,1,16,1,199,0,0,0,255,0,1,4,48,0,2,0,0,0,0,0,2,0,2,0,0,0,3,0,29,0,0,0,32,3,48,0,57,0,1,0,0,0,3,0,29,0,0,0,239,0,33,4,35,0,0,0,2,3,0,0,41,0,0,0,32,2,48,1,26,0,0,0,0,2,1,3,85,0,0,0,72,1,0,0,65,0,0,0,1,2,0,0,41,0,0,0,32,2,32,1,26,0,0,0,0,2,18,1,189,0,0,0,0,1,3,0,25,0,0,0,2,0,0,0,5,0,0,0,0,0,1,4,45,0,0,0,2,3,0,0,41,0,0,0,32,2,48,1,26,0,0,0,0,2,1,3,85,0,0,0,80,1,0,0,65,0,0,0,1,2,0,0,41,0,0,0,32,2,32,1,26,0,0,0,0,2,18,1,141,0,0,0,0,1,3,0,25,0,0,0,2,0,0,0,5,0,0,0,0,0,1,4,45,0,0,0,0,0,18,4,27,0,0,0,0,0,1,4,45,0,0,0,0,1,1,4,26,0,0,0,0,0,1,4,45,0,0,0,253,0,0,4,50,0,0,0,254,0,1,4,46,0,0,0,255,0,1,4,48,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,1,0,0,0,0,0,0,0,0,0,24,6,170,24,150,187,242,101,104,232,132,167,55,75,65,224,2,80,9,98,202,186,106,21,2,58,141,144,232,80,139,131,2,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,54,218,214,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,109,76,230,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,124,245,218,176,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,0,0,0,0,0,0,0,0,78,72,123,113,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,84,104,105,115,32,109,101,116,104,111,100,32,97,108,119,97,121,115,32,114,101,118,101,114,116,115,0,0,0,0,0,0,8,195,121,160,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,100,0,0,0,0,0,0,0,0,0,0,0,0,127,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]]}}],\"id\":1}"); } @Test @@ -125,7 +125,7 @@ void ethEstimateGas_DeployContract() throws Exception { zkSync.ethEstimateGas(estimate).send(); - verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_estimateGas\",\"params\":[{\"from\":\"0x7e5f4552091a69125d5dfcb7b8c2659029395bdf\",\"to\":\"0x0000000000000000000000000000000000008006\",\"gas\":\"0x0\",\"gasPrice\":\"0x0\",\"data\":\"0x1415dae2000000000000000000000000000000000000000000000000000000000000000000379c09b5568d43b0ac6533a2672ee836815530b412f082f0b2e69915aa50fc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000\",\"transactionType\":\"0x71\",\"eip712Meta\":{\"ergsPerPubdata\":\"0x27100\",\"factoryDeps\":[[0,0,0,43,4,0,0,65,0,0,0,0,1,65,1,111,0,0,0,44,4,0,0,65,0,0,0,0,0,20,3,118,0,0,0,45,1,0,0,65,0,0,0,0,0,33,3,118,0,0,0,0,1,48,0,76,0,0,0,9,0,0,97,61,0,165,0,10,0,0,3,79,0,165,0,31,0,0,3,79,0,0,0,128,1,0,0,57,0,0,0,64,2,0,0,57,0,0,0,0,0,18,3,118,0,0,0,0,1,0,3,87,0,0,0,0,1,16,0,76,0,0,0,29,0,0,193,61,0,0,0,45,1,0,0,65,0,0,0,0,1,1,3,117,0,0,0,0,1,16,0,76,0,0,0,24,0,0,193,61,0,0,0,128,1,0,0,57,0,0,0,0,2,0,0,25,0,0,0,0,3,0,0,25,0,165,0,150,0,0,3,79,0,0,0,32,1,0,0,57,0,0,0,0,0,16,3,118,0,0,0,0,0,1,3,118,0,0,0,46,1,0,0,65,0,0,0,166,0,1,3,112,0,0,0,0,1,0,0,25,0,0,0,167,0,1,3,114,0,1,0,0,0,0,0,2,0,0,0,128,6,0,0,57,0,0,0,64,5,0,0,57,0,0,0,0,0,101,3,118,0,0,0,45,1,0,0,65,0,0,0,0,1,1,3,117,0,0,0,4,1,16,0,140,0,0,0,90,0,0,65,61,0,0,0,44,1,0,0,65,0,0,0,0,1,1,3,117,0,0,0,0,1,1,3,119,0,0,0,47,2,0,0,65,0,0,0,0,1,33,1,111,0,0,0,48,2,16,0,156,0,0,0,68,0,0,193,61,0,0,0,0,1,0,3,87,0,0,0,0,1,16,0,76,0,0,0,92,0,0,193,61,0,0,0,45,1,0,0,65,0,0,0,0,1,1,3,117,0,0,0,4,1,16,0,138,0,0,0,1,2,0,0,138,0,0,0,50,3,0,0,65,0,0,0,0,2,33,0,75,0,0,0,0,2,0,0,25,0,0,0,0,2,3,32,25,0,0,0,0,1,49,1,111,0,0,0,0,4,49,1,63,0,0,0,50,1,16,0,156,0,0,0,0,1,0,0,25,0,0,0,0,1,3,64,25,0,0,0,50,3,64,0,156,0,0,0,0,1,2,192,25,0,0,0,0,1,16,0,76,0,0,0,94,0,0,193,61,0,0,0,0,1,0,0,25,0,0,0,167,0,1,3,114,0,0,0,49,1,16,0,156,0,0,0,90,0,0,193,61,0,0,0,0,1,0,3,87,0,0,0,0,1,16,0,76,0,0,0,101,0,0,193,61,0,0,0,45,1,0,0,65,0,0,0,0,1,1,3,117,0,0,0,4,1,16,0,138,0,0,0,50,2,0,0,65,0,0,0,31,3,16,0,140,0,0,0,0,3,0,0,25,0,0,0,0,3,2,32,25,0,0,0,0,1,33,1,111,0,0,0,0,4,16,0,76,0,0,0,0,2,0,128,25,0,0,0,50,1,16,0,156,0,0,0,0,1,3,0,25,0,0,0,0,1,2,96,25,0,0,0,0,1,16,0,76,0,0,0,103,0,0,193,61,0,0,0,0,1,0,0,25,0,0,0,167,0,1,3,114,0,0,0,0,1,0,0,25,0,0,0,167,0,1,3,114,0,0,0,0,1,0,0,25,0,0,0,167,0,1,3,114,0,0,0,0,1,0,0,25,0,1,0,0,0,6,0,29,0,165,0,139,0,0,3,79,0,0,0,1,2,0,0,41,0,0,0,0,0,18,3,118,0,0,0,52,1,0,0,65,0,0,0,166,0,1,3,112,0,0,0,0,1,0,0,25,0,0,0,167,0,1,3,114,0,0,0,44,1,0,0,65,0,0,0,0,1,1,3,117,0,0,0,4,1,16,0,57,0,0,0,0,1,1,3,119,0,1,0,0,0,5,0,29,0,165,0,114,0,0,3,79,0,0,0,1,1,0,0,41,0,0,0,0,1,1,3,117,0,0,0,51,2,0,0,65,0,0,0,0,1,33,1,111,0,0,0,166,0,1,3,112,0,2,0,0,0,0,0,2,0,0,0,1,2,0,0,138,0,1,0,0,0,1,0,29,0,0,0,0,1,33,1,63,0,2,0,0,0,1,0,29,0,0,0,0,1,0,0,25,0,165,0,139,0,0,3,79,0,0,0,2,2,0,0,41,0,0,0,0,2,33,0,75,0,0,0,130,0,0,33,61,0,0,0,1,2,0,0,41,0,0,0,0,1,33,0,25,0,0,0,0,2,0,0,25,0,165,0,137,0,0,3,79,0,0,0,2,0,0,0,5,0,0,0,0,0,1,3,111,0,0,0,53,1,0,0,65,0,0,0,0,0,16,3,118,0,0,0,17,1,0,0,57,0,0,0,4,2,0,0,57,0,0,0,0,0,18,3,118,0,0,0,54,1,0,0,65,0,0,0,167,0,1,3,114,0,0,0,0,0,18,3,91,0,0,0,0,0,1,3,111,0,0,0,0,1,1,3,89,0,0,0,0,0,1,3,111,0,0,0,0,4,1,3,117,0,0,0,0,4,52,1,207,0,0,0,0,4,52,2,47,0,0,1,0,3,48,0,137,0,0,0,0,2,50,2,47,0,0,0,0,2,50,1,207,0,0,0,0,2,66,1,159,0,0,0,0,0,33,3,118,0,0,0,0,0,1,3,111,0,0,0,5,4,48,2,112,0,0,0,0,5,64,0,76,0,0,0,158,0,0,97,61,0,0,0,0,0,33,3,118,0,0,0,32,1,16,0,57,0,0,0,1,4,64,0,138,0,0,0,0,5,64,0,76,0,0,0,153,0,0,193,61,0,0,0,31,3,48,1,143,0,0,0,0,4,48,0,76,0,0,0,164,0,0,97,61,0,0,0,3,3,48,2,16,0,165,0,141,0,0,3,79,0,0,0,0,0,1,3,111,0,0,0,0,0,1,3,111,0,0,0,165,0,0,3,116,0,0,0,166,0,1,3,112,0,0,0,167,0,1,3,114,0,0,0,0,0,0,224,1,0,0,0,0,0,0,224,1,0,0,0,0,0,0,224,1,0,0,0,0,0,0,224,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,224,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,109,76,230,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,124,245,218,176,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,128,78,72,123,113,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,36,0,0,0,0,0,0,0,0]]}}],\"id\":1}"); + verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_estimateGas\",\"params\":[{\"from\":\"0x7e5f4552091a69125d5dfcb7b8c2659029395bdf\",\"to\":\"0x0000000000000000000000000000000000008006\",\"gas\":\"0x0\",\"gasPrice\":\"0x0\",\"data\":\"0x3cda33510000000000000000000000000000000000000000000000000000000000000000010000517112c421df08d7b49e4dc1312f4ee62268ee4f5683b11d9e2d33525a00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000\",\"transactionType\":\"0x71\",\"eip712Meta\":{\"ergsPerPubdata\":\"0x27100\",\"factoryDeps\":[[0,2,0,0,0,0,0,2,0,1,0,0,0,1,3,85,0,0,0,96,1,16,2,112,0,0,0,65,0,16,1,157,0,0,0,1,1,32,1,143,0,0,0,0,1,16,0,76,0,0,0,8,0,0,193,61,0,253,0,24,0,0,4,15,0,253,0,9,0,0,4,15,0,0,0,128,1,0,0,57,0,0,0,64,2,0,0,57,0,0,0,0,0,18,4,53,0,0,0,0,1,0,4,22,0,0,0,0,1,16,0,76,0,0,0,22,0,0,193,61,0,0,0,32,1,0,0,57,0,0,1,0,2,0,0,57,0,0,0,0,0,18,4,57,0,0,1,32,1,0,0,57,0,0,0,0,0,1,4,57,0,0,0,66,1,0,0,65,0,0,0,254,0,1,4,46,0,0,0,0,1,0,0,25,0,0,0,255,0,1,4,48,0,4,0,0,0,0,0,2,0,0,0,0,1,0,4,16,0,0,128,2,2,16,0,140,0,0,0,51,0,0,97,61,0,0,0,0,2,0,4,17,0,0,128,1,2,32,0,140,0,0,0,51,0,0,97,61,0,0,0,67,2,0,0,65,0,0,0,0,0,32,4,57,0,0,0,4,2,0,0,57,0,0,0,0,0,18,4,57,0,0,0,68,1,0,0,65,0,0,128,2,2,0,0,57,0,0,0,0,3,0,4,21,0,0,0,4,3,48,0,138,0,0,0,32,3,48,0,201,0,253,0,224,0,0,4,15,0,0,0,255,1,0,0,57,0,0,0,3,1,16,2,79,0,0,0,0,1,16,0,76,0,0,0,86,0,0,97,61,0,0,0,4,1,0,3,95,0,0,0,0,1,1,4,59,0,0,0,0,1,16,0,76,0,0,0,51,0,0,193,61,0,0,0,0,1,0,0,25,0,0,0,254,0,1,4,46,0,0,0,128,1,0,0,57,0,0,0,64,6,0,0,57,0,0,0,0,0,22,4,53,0,0,0,0,1,0,0,49,0,0,0,3,2,16,0,140,0,0,0,84,0,0,161,61,0,0,0,1,2,0,3,103,0,0,0,0,3,2,4,59,0,0,0,224,3,48,2,112,0,0,0,69,4,48,0,156,0,0,0,108,0,0,97,61,0,0,0,70,2,48,0,156,0,0,0,88,0,0,97,61,0,0,0,71,2,48,0,156,0,0,0,84,0,0,193,61,0,0,0,0,2,0,4,22,0,0,0,0,2,32,0,76,0,0,0,128,0,0,193,61,0,0,0,4,1,16,0,138,0,0,0,72,2,0,0,65,0,0,0,31,3,16,0,140,0,0,0,0,3,0,0,25,0,0,0,0,3,2,32,25,0,0,0,72,1,16,1,151,0,0,0,0,4,16,0,76,0,0,0,0,2,0,128,25,0,0,0,72,1,16,0,156,0,0,0,0,1,3,0,25,0,0,0,0,1,2,96,25,0,0,0,0,1,16,0,76,0,0,0,142,0,0,193,61,0,0,0,0,1,0,0,25,0,0,0,255,0,1,4,48,0,0,0,0,1,0,0,25,0,0,0,255,0,1,4,48,0,0,0,0,1,0,0,25,0,0,0,255,0,1,4,48,0,0,0,0,2,0,4,22,0,0,0,0,2,32,0,76,0,0,0,126,0,0,193,61,0,0,0,4,1,16,0,138,0,0,0,1,2,0,0,138,0,0,0,72,3,0,0,65,0,0,0,0,2,33,0,75,0,0,0,0,2,0,0,25,0,0,0,0,2,3,32,25,0,0,0,72,1,16,1,151,0,0,0,72,4,16,0,156,0,0,0,0,3,0,128,25,0,0,0,72,1,16,1,103,0,0,0,72,1,16,0,156,0,0,0,0,1,2,0,25,0,0,0,0,1,3,96,25,0,0,0,0,1,16,0,76,0,0,0,132,0,0,193,61,0,0,0,0,1,0,0,25,0,0,0,255,0,1,4,48,0,0,0,0,3,0,4,22,0,0,0,0,3,48,0,76,0,0,0,130,0,0,193,61,0,0,0,4,1,16,0,138,0,0,0,72,3,0,0,65,0,0,0,63,4,16,0,140,0,0,0,0,4,0,0,25,0,0,0,0,4,3,32,25,0,0,0,72,1,16,1,151,0,0,0,0,5,16,0,76,0,0,0,0,3,0,128,25,0,0,0,72,1,16,0,156,0,0,0,0,1,4,0,25,0,0,0,0,1,3,96,25,0,0,0,0,1,16,0,76,0,0,0,162,0,0,193,61,0,0,0,0,1,0,0,25,0,0,0,255,0,1,4,48,0,0,0,0,1,0,0,25,0,0,0,255,0,1,4,48,0,0,0,0,1,0,0,25,0,0,0,255,0,1,4,48,0,0,0,0,1,0,0,25,0,0,0,255,0,1,4,48,0,0,0,0,1,0,0,25,0,2,0,0,0,6,0,29,0,253,0,251,0,0,4,15,0,0,0,2,2,0,0,41,0,0,0,0,2,2,4,51,0,0,0,0,0,18,4,53,0,0,0,64,1,32,2,16,0,0,0,73,1,16,1,151,0,0,0,76,1,16,1,199,0,0,0,254,0,1,4,46,0,2,0,0,0,6,0,29,0,0,0,0,1,0,0,25,0,253,0,251,0,0,4,15,0,0,0,1,2,0,3,103,0,0,0,4,2,32,3,112,0,0,0,0,2,2,4,59,0,0,0,0,1,18,0,25,0,0,0,0,2,33,0,75,0,0,0,0,2,0,0,25,0,0,0,1,2,0,64,57,0,0,0,1,2,32,1,143,0,0,0,0,2,32,0,76,0,0,0,190,0,0,97,61,0,0,0,74,1,0,0,65,0,0,0,0,0,16,4,53,0,0,0,17,1,0,0,57,0,0,0,4,2,0,0,57,0,0,0,0,0,18,4,53,0,0,0,75,1,0,0,65,0,0,0,255,0,1,4,48,0,0,0,36,1,32,3,112,0,0,0,0,2,1,4,59,0,0,0,0,1,32,0,76,0,0,0,0,1,0,0,25,0,0,0,1,1,0,192,57,0,0,0,0,1,18,0,75,0,0,0,197,0,0,193,61,0,1,0,0,0,2,0,29,0,2,0,0,0,6,0,29,0,0,0,0,1,0,0,25,0,253,0,251,0,0,4,15,0,0,0,1,2,0,3,103,0,0,0,4,2,32,3,112,0,0,0,0,2,2,4,59,0,0,0,0,1,18,0,25,0,0,0,0,2,33,0,75,0,0,0,0,2,0,0,25,0,0,0,1,2,0,64,57,0,0,0,1,2,32,1,143,0,0,0,0,2,32,0,76,0,0,0,199,0,0,97,61,0,0,0,74,1,0,0,65,0,0,0,0,0,16,4,53,0,0,0,17,1,0,0,57,0,0,0,4,2,0,0,57,0,0,0,0,0,18,4,53,0,0,0,75,1,0,0,65,0,0,0,255,0,1,4,48,0,0,0,0,2,0,0,25,0,253,0,249,0,0,4,15,0,0,0,2,1,0,0,41,0,0,0,0,1,1,4,51,0,0,0,64,1,16,2,16,0,0,0,73,1,16,1,151,0,0,0,254,0,1,4,46,0,0,0,0,1,0,0,25,0,0,0,255,0,1,4,48,0,0,0,0,2,0,0,25,0,253,0,249,0,0,4,15,0,0,0,2,1,0,0,41,0,0,0,0,1,1,4,51,0,0,0,1,2,0,0,41,0,0,0,0,2,32,0,76,0,0,0,209,0,0,193,61,0,0,0,64,1,16,2,16,0,0,0,73,1,16,1,151,0,0,0,254,0,1,4,46,0,0,0,68,2,16,0,57,0,0,0,77,3,0,0,65,0,0,0,0,0,50,4,53,0,0,0,36,2,16,0,57,0,0,0,26,3,0,0,57,0,0,0,0,0,50,4,53,0,0,0,78,2,0,0,65,0,0,0,0,0,33,4,53,0,0,0,4,2,16,0,57,0,0,0,32,3,0,0,57,0,0,0,0,0,50,4,53,0,0,0,64,1,16,2,16,0,0,0,73,1,16,1,151,0,0,0,79,1,16,1,199,0,0,0,255,0,1,4,48,0,2,0,0,0,0,0,2,0,2,0,0,0,3,0,29,0,0,0,32,3,48,0,57,0,1,0,0,0,3,0,29,0,0,0,239,0,33,4,35,0,0,0,2,3,0,0,41,0,0,0,32,2,48,1,26,0,0,0,0,2,1,3,85,0,0,0,72,1,0,0,65,0,0,0,1,2,0,0,41,0,0,0,32,2,32,1,26,0,0,0,0,2,18,1,189,0,0,0,0,1,3,0,25,0,0,0,2,0,0,0,5,0,0,0,0,0,1,4,45,0,0,0,2,3,0,0,41,0,0,0,32,2,48,1,26,0,0,0,0,2,1,3,85,0,0,0,80,1,0,0,65,0,0,0,1,2,0,0,41,0,0,0,32,2,32,1,26,0,0,0,0,2,18,1,141,0,0,0,0,1,3,0,25,0,0,0,2,0,0,0,5,0,0,0,0,0,1,4,45,0,0,0,0,0,18,4,27,0,0,0,0,0,1,4,45,0,0,0,0,1,1,4,26,0,0,0,0,0,1,4,45,0,0,0,253,0,0,4,50,0,0,0,254,0,1,4,46,0,0,0,255,0,1,4,48,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,1,0,0,0,0,0,0,0,0,0,24,6,170,24,150,187,242,101,104,232,132,167,55,75,65,224,2,80,9,98,202,186,106,21,2,58,141,144,232,80,139,131,2,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,54,218,214,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,109,76,230,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,124,245,218,176,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,0,0,0,0,0,0,0,0,78,72,123,113,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,84,104,105,115,32,109,101,116,104,111,100,32,97,108,119,97,121,115,32,114,101,118,101,114,116,115,0,0,0,0,0,0,8,195,121,160,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,100,0,0,0,0,0,0,0,0,0,0,0,0,127,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]]}}],\"id\":1}"); } @Test diff --git a/src/test/java/io/zksync/utils/ContractDeployerTest.java b/src/test/java/io/zksync/utils/ContractDeployerTest.java index f04a72e..86bfb56 100644 --- a/src/test/java/io/zksync/utils/ContractDeployerTest.java +++ b/src/test/java/io/zksync/utils/ContractDeployerTest.java @@ -12,7 +12,7 @@ public class ContractDeployerTest { @Test public void computeL2Create2AddressActual() { - String expected = "0x14ba05281495657b009103686f366d7761e7535b"; + String expected = "0x0790aff699b38f40929840469a72fb40e9763716"; byte[] salt = new byte[32]; Address result = ContractDeployer.computeL2Create2Address(new Address("0xa909312acfc0ed4370b8bd20dfe41c8ff6595194"), Numeric.hexStringToByteArray(CounterContract.BINARY), new byte[] {}, salt); @@ -31,7 +31,7 @@ public void computeL2CreateAddressActual() { @Test public void hashBytecode() { - String expected = "0x00379c09b5568d43b0ac6533a2672ee836815530b412f082f0b2e69915aa50fc"; + String expected = "0x010000517112c421df08d7b49e4dc1312f4ee62268ee4f5683b11d9e2d33525a"; byte[] result = ContractDeployer.hashBytecode(Numeric.hexStringToByteArray(CounterContract.BINARY)); String resultHex = Numeric.toHexString(result); diff --git a/src/test/java/io/zksync/utils/MessengerTest.java b/src/test/java/io/zksync/utils/MessengerTest.java index 7c0c980..ae96a91 100644 --- a/src/test/java/io/zksync/utils/MessengerTest.java +++ b/src/test/java/io/zksync/utils/MessengerTest.java @@ -4,7 +4,11 @@ import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import org.web3j.abi.EventEncoder; +import org.web3j.abi.TypeReference; import org.web3j.abi.datatypes.Address; +import org.web3j.abi.datatypes.Event; +import org.web3j.abi.datatypes.generated.Uint256; import org.web3j.crypto.Hash; import org.web3j.utils.Numeric; diff --git a/src/test/resources/constructorContractBinary.hex b/src/test/resources/constructorContractBinary.hex index aca061a..37458fd 100644 --- a/src/test/resources/constructorContractBinary.hex +++ b/src/test/resources/constructorContractBinary.hex @@ -1 +1 @@ -0x0000004a011001970000004b0400004100000000001403760000004c010000410000000000210376000000000130004c000000080000613d012400090000034f012400890000034f00020000000000020000000001000357000000000110004c0000001c0000c13d0000004c0100004100000000030103750000009f02300039000000200100008a000000000212016f000000800420008a0000004d0440009c0000001e0000413d0000004f01000041000000000010037600000041010000390000000402000039000000000012037600000050010000410000012600010372000000000100001900000126000103720000004004000039000200000004001d00000000002403760000004c020000410000000002020375000000000220004c0000002b0000c13d00000080010000390000000002000019000100000003001d012401150000034f0000000103000029000000490000013d0000001f0230018f0000004b0400004100000000080403750000000504300270000000000540004c0000003a0000613d0000000005000019000000050650021000000000076800190000000007070377000000800660003900000000007603760000000105500039000000000645004b000000320000413d000000000420004c000000490000613d000000000113016f000000000518001900000003022002100000008001100039000000000401037500000000042401cf000000000424022f00000000050503770000010002200089000000000525022f00000000022501cf000000000242019f00000000002103760000004e010000410000005f0230008c000000000200001900000000020120190000004e03300197000000000430004c00000000010080190000004e0330009c000000000102c019000000000110004c000000560000c13d00000000010000190000012600010372000000c0010000390000000005010375000000000150004c0000000001000019000000010100c039000000000115004b0000006e0000c13d000000a001000039000000000101037500000080020000390000000002020375000000000320004c000000700000613d000000010300008a00000000432300d9000000000331004b000000700000a13d0000004f010000410000000000100376000000110100003900000004020000390000000000120376000000500100004100000126000103720000000001000019000001260001037200000000212100a90000000002000019000100000005001d012401080000034f0000000101000029000000000110004c000000790000613d000000000100001900000126000103720000004c010000410000000001010375000000000110004c000000820000c13d0000000201000029000000000101037500000000020000190000000003000019012401150000034f000000200100003900000051020000410000000000120376000000520100004100000000000103760000005301000041000001250001037000030000000000020000000001000350000080020210008c000000a60000613d0000000002000351000080010220008c000000a60000613d00000054020000410000005503000041000000000023037600000056020000410000000000120376000080020100003900000057020000410000000003000356000000030330008a00000020033000c9012400d40000034f000000ff01000039000000020110024f000000000110004c000000a40000613d0000005801000041000000030110017f0000000001010378000000000110004c000000a60000c13d000000000100001900000125000103700000008005000039000000400100003900000000005103760000004c010000410000000001010375000000030110008c000000c90000a13d0000004b010000410000000001010375000000000101037700000059011001970000005a0110009c000000c90000c13d0000000001000357000000000110004c000000cb0000c13d0000004c010000410000000001010375000000040110008a000000010200008a0000004e03000041000000000221004b000000000200001900000000020320190000004e011001970000004e0410009c00000000030080190000004e011001670000004e0110009c00000000010200190000000001036019000000000110004c000000cd0000c13d0000000001000019000001260001037200000000010000190000012600010372000000000100001900000126000103720000000001000019000100000005001d0124010a0000034f000000010200002900000000001203760000005b0100004100000125000103700002000000000002000200000003001d0000002003300039000100000003001d000000ed002103650000000205000029000000200250011a000000000201001f0000000106000029000000202160011a000000000126004900000003022002100000010003200089000000200110011a000000010331025f000000000101003100000000042101cf000000000343019f000000000220004c000000000103c019000000200260011a0000004e021001cd00000000010500190000000200000005000000000001036f0000000103000029000000020500002900000000020000190000000102004039000000010220018f000000000220004c000001070000c13d000000200250011a000000000201001f0000000006030019000000202160011a000000000126004900000003022002100000010003200089000000200110011a000000010331025f000000000101003100000000042101cf000000000343019f000000000220004c000000000103c019000000200260011a0000005c0210019d00000000010500190000000200000005000000000001036f0000000000010371000000000012035b000000000001036f0000000001010359000000000001036f000000000401037500000000043401cf000000000434022f0000010003300089000000000232022f00000000023201cf000000000242019f0000000000210376000000000001036f0000000504300270000000000540004c0000011d0000613d00000000002103760000002001100039000000010440008a000000000540004c000001180000c13d0000001f0330018f000000000430004c000001230000613d00000003033002100124010c0000034f000000000001036f000000000001036f000001240000037400000125000103700000012600010372000000000000e0010000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000000ffffe00000000000000000000000000000000000000000000000000000000000ffffc0000000000000000000000000000000000000000000000000ffffffffffffff8080000000000000000000000000000000000000000000000000000000000000004e487b710000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000e000200000000000000000000000000000000000000000000000400000000000e000001806aa1896bbf26568e884a7374b41e002500962caba6a15023a8d90e8508b830000000000000000000000000000000000000000000000000000000000fff8000000000000000000000000000000000000000000000000000000000000fff8040000000000000000000000000000000000000000000000240000000000fff800000000000000000000000000000000000000000000000000ffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000006d4ce63c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff \ No newline at end of file +0x000200000000000200010000000103550000006001100270000000370010019d000000010120018f000000000110004c000000080000c13d00d700730000040f00d700090000040f00010000000000020000000001000416000000000110004c0000001a0000c13d00000000010000310000009f02100039000000200300008a000000000232016f0000007f0320008c0000001c0000213d000000390100004100000000001004350000004101000039000000040200003900000000001204350000003a01000041000000d9000104300000000001000019000000d900010430000000400300003900000000002304350000001f0210018f00000001030003670000000504100270000000000540004c0000002c0000613d00000000050000190000000506500210000000000763034f000000000707043b000000800660003900000000007604350000000105500039000000000645004b000000240000413d000000000520004c0000003b0000613d0000000504400210000000000343034f00000003022002100000008004400039000000000504043300000000052501cf000000000525022f000000000303043b0000010002200089000000000323022f00000000022301cf000000000252019f000000000024043500000038020000410000005f0310008c000000000300001900000000030220190000003801100197000000000410004c0000000002008019000000380110009c00000000010300190000000001026019000000000110004c000000490000c13d0000000001000019000000d900010430000000c0010000390000000005010433000000000150004c0000000001000019000000010100c039000000000115004b000000610000c13d000000a001000039000000000101043300000080020000390000000002020433000000000320004c000000630000613d000000010300008a00000000432300d9000000000331004b000000630000a13d000000390100004100000000001004350000001101000039000000040200003900000000001204350000003a01000041000000d9000104300000000001000019000000d90001043000000000212100a90000000002000019000100000005001d00d700d30000040f0000000101000029000000000110004c0000006c0000613d0000000001000019000000d900010430000000200100003900000100020000390000000000120439000001200100003900000000000104390000003b01000041000000d80001042e00030000000000020000000001000410000080020210008c0000008e0000613d0000000002000411000080010220008c0000008e0000613d0000003c020000410000000000200439000000040200003900000000001204390000003d0100004100008002020000390000000003000415000000030330008a00000020033000c900d700ba0000040f000000ff01000039000000020110024f000000000110004c000000af0000613d000000030100035f000000000101043b000000000110004c0000008e0000c13d0000000001000019000000d80001042e0000008005000039000000400100003900000000005104350000000001000031000000030210008c000000ad0000a13d0000000102000367000000000202043b0000003e022001970000003f0220009c000000ad0000c13d0000000002000416000000000220004c000000b10000c13d000000040110008a000000010200008a0000003803000041000000000221004b000000000200001900000000020320190000003801100197000000380410009c00000000030080190000003801100167000000380110009c00000000010200190000000001036019000000000110004c000000b30000c13d0000000001000019000000d9000104300000000001000019000000d9000104300000000001000019000000d9000104300000000001000019000000d9000104300000000001000019000100000005001d00d700d50000040f000000010200002900000000001204350000004001000041000000d80001042e0002000000000002000200000003001d0000002003300039000100000003001d000000c9002104230000000203000029000000200230011a000000000201035500000038010000410000000102000029000000200220011a00000000021201bd00000000010300190000000200000005000000000001042d0000000203000029000000200230011a000000000201035500000041010000410000000102000029000000200220011a000000000212018d00000000010300190000000200000005000000000001042d000000000012041b000000000001042d000000000101041a000000000001042d000000d700000432000000d80001042e000000d9000104300000000000000001000000000000000100000000000000000000000000000000000000000000000000000000ffffffff80000000000000000000000000000000000000000000000000000000000000004e487b7100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000002000000000000000000000000000000400000010000000000000000001806aa1896bbf26568e884a7374b41e002500962caba6a15023a8d90e8508b830200020000000000000000000000000000000024000000000000000000000000ffffffff000000000000000000000000000000000000000000000000000000006d4ce63c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000008000000000000000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000 \ No newline at end of file