From d76b2c941ba14fd626ba4cc023d7df5559b1e834 Mon Sep 17 00:00:00 2001 From: lbqds Date: Fri, 6 Dec 2024 19:16:59 +0800 Subject: [PATCH 1/3] Update full node to 3.10.0 --- .project.json | 6 +++--- artifacts/add/Add.ral.json | 6 +++--- artifacts/add/AddMain.ral.json | 2 +- artifacts/add/DestroyAdd.ral.json | 2 +- artifacts/greeter/Greeter.ral.json | 2 +- artifacts/greeter/GreeterMain.ral.json | 2 +- artifacts/nft/DeprecatedNFTTest1.ral.json | 2 +- artifacts/nft/DeprecatedNFTTest2.ral.json | 2 +- artifacts/nft/DeprecatedNFTTest3.ral.json | 2 +- artifacts/nft/DeprecatedNFTTest4.ral.json | 2 +- artifacts/nft/DeprecatedNFTTest5.ral.json | 2 +- artifacts/nft/DeprecatedNFTTest6.ral.json | 2 +- artifacts/nft/DeprecatedNFTTest7.ral.json | 2 +- artifacts/nft/MintNFTTest.ral.json | 2 +- artifacts/nft/NFTCollectionTest.ral.json | 2 +- artifacts/nft/NFTCollectionWithRoyaltyTest.ral.json | 2 +- artifacts/nft/NFTTest.ral.json | 2 +- artifacts/nft/NFTTestStd.ral.json | 2 +- artifacts/nft/WithdrawNFTCollectionTest.ral.json | 2 +- artifacts/nft/WrongNFTTest.ral.json | 2 +- artifacts/sub/Sub.ral.json | 2 +- artifacts/test/Assert.ral.json | 2 +- artifacts/test/CallScript0.ral.json | 2 +- artifacts/test/CallScript1.ral.json | 2 +- artifacts/test/Debug.ral.json | 2 +- artifacts/test/Deposit.ral.json | 2 +- artifacts/test/DepositToken.ral.json | 2 +- artifacts/test/InsertIntoMap.ral.json | 2 +- artifacts/test/MapTest.ral.json | 2 +- artifacts/test/MapTestWrapper.ral.json | 2 +- artifacts/test/MetaData.ral.json | 2 +- artifacts/test/MultiDeposit.ral.json | 2 +- artifacts/test/MultiWithdraw.ral.json | 2 +- artifacts/test/OwnerOnly.ral.json | 2 +- artifacts/test/RemoveFromMap.ral.json | 2 +- artifacts/test/TemplateArrayVar.ral.json | 2 +- artifacts/test/TestAssert.ral.json | 2 +- artifacts/test/Transact.ral.json | 6 +++--- artifacts/test/UpdateMapValue.ral.json | 2 +- artifacts/test/UpdateUserAccount.ral.json | 2 +- artifacts/test/UserAccount.ral.json | 2 +- artifacts/test/Warnings.ral.json | 2 +- artifacts/test/Withdraw.ral.json | 2 +- artifacts/token/FakeTokenTest.ral.json | 2 +- artifacts/token/TokenTest.ral.json | 2 +- artifacts/token/TokenTestStd.ral.json | 2 +- artifacts/ts/Add.ts | 2 +- artifacts/ts/Transact.ts | 2 +- docker/docker-compose.yml | 2 +- packages/web3/package.json | 2 +- packages/web3/src/api/api-alephium.ts | 4 +++- 51 files changed, 59 insertions(+), 57 deletions(-) diff --git a/.project.json b/.project.json index 09e815e61..6eb72af13 100644 --- a/.project.json +++ b/.project.json @@ -1,5 +1,5 @@ { - "fullNodeVersion": "v3.9.1", + "fullNodeVersion": "v3.10.0", "compilerOptionsUsed": { "ignoreUnusedConstantsWarnings": false, "ignoreUnusedVariablesWarnings": false, @@ -15,7 +15,7 @@ "sourceFile": "add/add.ral", "sourceCodeHash": "e53e74ff98c352525e856abd4311868176d45c61c957791c3d42eae274088df0", "bytecodeDebugPatch": "=12-2+5c=2-2+81=3-1+e=2-2+bc=83-1+97e010a61646450726976617465=266", - "codeHashDebug": "c46db1ae7bae8b332c115869126eb1402bc71574925608a2adcea3cf7b9f8e7e" + "codeHashDebug": "c8b4522606d53c50b6ff00009a5072ceba32fd8de32b77033e8d74500ccba6d3" }, "AddMain": { "sourceFile": "add/add.ral", @@ -321,7 +321,7 @@ "sourceFile": "test/transact.ral", "sourceCodeHash": "732c5dee7df9c1362a8b97ec6308c94e38795d15341b900563b0005cb2c5261c", "bytecodeDebugPatch": "", - "codeHashDebug": "85e3e9a803741af8e92bd43b1b07cde53f39b86cab0ef1a85bab12b10d691b55" + "codeHashDebug": "0b6427253638fa8f32b04e7c5915d41d51b0148a8e219e4881eba5548a42ae41" }, "UpdateMapValue": { "sourceFile": "test/map.ral", diff --git a/artifacts/add/Add.ral.json b/artifacts/add/Add.ral.json index df1fcc96e..01e0718de 100644 --- a/artifacts/add/Add.ral.json +++ b/artifacts/add/Add.ral.json @@ -1,8 +1,8 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "Add", - "bytecode": "0206124024404f407440a140af010002100205d34fbb20db1600160100020201000c0c0205d36a51f82d1600160100020200000202021805160016015f06160016015f075da00016002a16012aa100a000160016010e0dce000100020103040c0011d319adf50e1300641600130164170517041603d1a21601160216041605c118010104060015d3f6ce55a6130064160013016417051704160316021340c8ac1603d1a21601160216041605c118010201010003d320f98f621600b0", - "codeHash": "6a1f1415a68d55365e205b39e5418cd1f6fc8c2c7926d3662c77d69b55c92681", + "bytecode": "0206124024404f407440a140af010002020205d34fbb20db1600160100020201000c0c0205d36a51f82d1600160100020200000202021805160016015f06160016015f075da00016002a16012aa100a000160016010e0dce00010002010304060011d319adf50e1300641600130164170517041603d1a21601160216041605c118010104060015d3f6ce55a6130064160013016417051704160316021340c8ac1603d1a21601160216041605c118010201010003d320f98f621600b0", + "codeHash": "630de1d7741f1c7f5727b26fc099111ff2b96ca85388f013eb5e3ec1cb3cfcf9", "fieldsSig": { "names": [ "sub", diff --git a/artifacts/add/AddMain.ral.json b/artifacts/add/AddMain.ral.json index 487c76fb5..861215aec 100644 --- a/artifacts/add/AddMain.ral.json +++ b/artifacts/add/AddMain.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "AddMain", "bytecodeTemplate": "0101030002000c{1}{2}17011700160016010e0e{0}01001818", "fieldsSig": { diff --git a/artifacts/add/DestroyAdd.ral.json b/artifacts/add/DestroyAdd.ral.json index e7929ec86..df383fc52 100644 --- a/artifacts/add/DestroyAdd.ral.json +++ b/artifacts/add/DestroyAdd.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "DestroyAdd", "bytecodeTemplate": "01010300000005{1}0d0c{0}0105", "fieldsSig": { diff --git a/artifacts/greeter/Greeter.ral.json b/artifacts/greeter/Greeter.ral.json index 8b013bbc6..75f440506 100644 --- a/artifacts/greeter/Greeter.ral.json +++ b/artifacts/greeter/Greeter.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "Greeter", "bytecode": "190111010000000106d3952f757b030c7bce0002", "codeHash": "4bbf82c83dcb0a3df905c290fbc12a19ce5160a7b655c1a347913481da12d747", diff --git a/artifacts/greeter/GreeterMain.ral.json b/artifacts/greeter/GreeterMain.ral.json index b577f728f..0baa21891 100644 --- a/artifacts/greeter/GreeterMain.ral.json +++ b/artifacts/greeter/GreeterMain.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "GreeterMain", "bytecodeTemplate": "01010300020014{0}17000c0d160001000d2f0c7b{0}17010c0d1601d4952f757b0d2f0c7b", "fieldsSig": { diff --git a/artifacts/nft/DeprecatedNFTTest1.ral.json b/artifacts/nft/DeprecatedNFTTest1.ral.json index af914c487..d71fe2ddc 100644 --- a/artifacts/nft/DeprecatedNFTTest1.ral.json +++ b/artifacts/nft/DeprecatedNFTTest1.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "DeprecatedNFTTest1", "bytecode": "02010e010000000103d3ee6a5cd5ce0102", "codeHash": "cc6928c9c6777077abcb5b9c4f7c5d620d6cae07ec6f00f5e8b0efe6a7b913c4", diff --git a/artifacts/nft/DeprecatedNFTTest2.ral.json b/artifacts/nft/DeprecatedNFTTest2.ral.json index 94209890a..091b818e1 100644 --- a/artifacts/nft/DeprecatedNFTTest2.ral.json +++ b/artifacts/nft/DeprecatedNFTTest2.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "DeprecatedNFTTest2", "bytecode": "02020e1c010000000103d3ee6a5cd5ce0102010000000103d33e65d93dce0002", "codeHash": "ade9aee476ee752050a1e9e1b19039f05261cb3f53941152617174faf9eae572", diff --git a/artifacts/nft/DeprecatedNFTTest3.ral.json b/artifacts/nft/DeprecatedNFTTest3.ral.json index c5dbf35fa..399a0008b 100644 --- a/artifacts/nft/DeprecatedNFTTest3.ral.json +++ b/artifacts/nft/DeprecatedNFTTest3.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "DeprecatedNFTTest3", "bytecode": "02020e19010000000103d3ee6a5cd5ce0102010000000001d34d12f529", "codeHash": "465bc3739cd1649e58e0470971bd2fabf21363ab9fc2c15052fb2440dd06ada5", diff --git a/artifacts/nft/DeprecatedNFTTest4.ral.json b/artifacts/nft/DeprecatedNFTTest4.ral.json index 36174e232..bc24cab44 100644 --- a/artifacts/nft/DeprecatedNFTTest4.ral.json +++ b/artifacts/nft/DeprecatedNFTTest4.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "DeprecatedNFTTest4", "bytecode": "02020e1b010000000103d3ee6a5cd5ce0102010000000103d35f9a418a0402", "codeHash": "a5de0fa0b3580303ac63423f09ce5ed95fccbf789679b32130a53c26fef182e9", diff --git a/artifacts/nft/DeprecatedNFTTest5.ral.json b/artifacts/nft/DeprecatedNFTTest5.ral.json index 2d5ff1dbf..84c7168f9 100644 --- a/artifacts/nft/DeprecatedNFTTest5.ral.json +++ b/artifacts/nft/DeprecatedNFTTest5.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "DeprecatedNFTTest5", "bytecode": "02020e1e010000000103d3ee6a5cd5ce0102010000000305d35c9ec8a3ce000c0c02", "codeHash": "8b1374f39db98c485af3dd05d0b0ce861e9528f290ca9dc0d7108e8b48b50161", diff --git a/artifacts/nft/DeprecatedNFTTest6.ral.json b/artifacts/nft/DeprecatedNFTTest6.ral.json index 3c035c54d..ad225ff74 100644 --- a/artifacts/nft/DeprecatedNFTTest6.ral.json +++ b/artifacts/nft/DeprecatedNFTTest6.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "DeprecatedNFTTest6", "bytecode": "02020e1c010000000103d3ee6a5cd5ce0102010000000204d30e0a3ac10c0d02", "codeHash": "8bc0d39f0607d4a771ec70ae1057b71dbcde404177cb3b25fd7d93d553a2b8cd", diff --git a/artifacts/nft/DeprecatedNFTTest7.ral.json b/artifacts/nft/DeprecatedNFTTest7.ral.json index e308beed4..307078453 100644 --- a/artifacts/nft/DeprecatedNFTTest7.ral.json +++ b/artifacts/nft/DeprecatedNFTTest7.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "DeprecatedNFTTest7", "bytecode": "02020e1d010000000103d3ee6a5cd5ce0102010000000204d3289dd321ce000b02", "codeHash": "b95c9acf088b090f5d9d34f28ab079cf22b9e53af8ae6864113c71172231ef4c", diff --git a/artifacts/nft/MintNFTTest.ral.json b/artifacts/nft/MintNFTTest.ral.json index b8eabe878..1f74a3db6 100644 --- a/artifacts/nft/MintNFTTest.ral.json +++ b/artifacts/nft/MintNFTTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "MintNFTTest", "bytecodeTemplate": "01010300000015{2}4c0ab413c40de0b6b3a7640000a2{1}0d0d{0}0107184a09b413c40de0b6b3a7640000a2{1}0d0d{0}010418", "fieldsSig": { diff --git a/artifacts/nft/NFTCollectionTest.ral.json b/artifacts/nft/NFTCollectionTest.ral.json index e538aacf9..819a035cc 100644 --- a/artifacts/nft/NFTCollectionTest.ral.json +++ b/artifacts/nft/NFTCollectionTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "NFTCollectionTest", "bytecode": "04050912402d4040408a010000000102ce0102010000000102a0000201000102010f16000001310c7b160040cb17011601c50d7b16010201000203000816010002170216001602410e7b01030105011fd3b8b591eeb41701b1a00016001406414c5048000313046413006417031702160113c40de0b6b3a7640000a2a00040ce00160216030d1601c91704a0000d2aa100160402", "codeHash": "087f9292bb326a4d39a6fac09928cb25edf2837718f830f3a166a937f8724779", diff --git a/artifacts/nft/NFTCollectionWithRoyaltyTest.ral.json b/artifacts/nft/NFTCollectionWithRoyaltyTest.ral.json index 4979e3eb2..e215ca01a 100644 --- a/artifacts/nft/NFTCollectionWithRoyaltyTest.ral.json +++ b/artifacts/nft/NFTCollectionWithRoyaltyTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "NFTCollectionWithRoyaltyTest", "bytecode": "06080912402d40404050405b406c40b6010000000102ce0102010000000102a0000201000102010f16000001310c7b160040cb17011601c50d7b16010201000203000816010002170216001602410e7b0100020201061601ce032c1367102d0201010202000316001601a9010202020008b4ce02450f7b16001601a801030105011fd3b8b591eeb41701b1a00016001406414c5048000313046413006417031702160113c40de0b6b3a7640000a2a00040ce00160216030d1601c91704a0000d2aa100160402", "codeHash": "3b64d5e360566a4e4f568f773536a3ea74e66d12231aa44f19d2214ba87b38d6", diff --git a/artifacts/nft/NFTTest.ral.json b/artifacts/nft/NFTTest.ral.json index 4f6bbe983..661efae79 100644 --- a/artifacts/nft/NFTTest.ral.json +++ b/artifacts/nft/NFTTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "NFTTest", "bytecode": "04020914010000000102ce0202010000000203ce00ce0102", "codeHash": "4897086210869e612d82995b765a447c5319a55a56e8a0c3c07b4d9ca81e15b1", diff --git a/artifacts/nft/NFTTestStd.ral.json b/artifacts/nft/NFTTestStd.ral.json index cfe373f54..77e100427 100644 --- a/artifacts/nft/NFTTestStd.ral.json +++ b/artifacts/nft/NFTTestStd.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "NFTTestStd", "bytecode": "040309144020010000000102ce0202010000000203ce00ce0102010000000002d36811cfdd02", "codeHash": "b7ff3fa8dfacc7ae5edbabd6573d0699dffc5a0f07ad14023f682a201b7bce55", diff --git a/artifacts/nft/WithdrawNFTCollectionTest.ral.json b/artifacts/nft/WithdrawNFTCollectionTest.ral.json index 191f795e2..96c50481b 100644 --- a/artifacts/nft/WithdrawNFTCollectionTest.ral.json +++ b/artifacts/nft/WithdrawNFTCollectionTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "WithdrawNFTCollectionTest", "bytecodeTemplate": "01010300000006b4{1}0e0c{0}0106", "fieldsSig": { diff --git a/artifacts/nft/WrongNFTTest.ral.json b/artifacts/nft/WrongNFTTest.ral.json index f3c2a61f4..f8798487c 100644 --- a/artifacts/nft/WrongNFTTest.ral.json +++ b/artifacts/nft/WrongNFTTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "WrongNFTTest", "bytecode": "04020917010000000102ce0202010000000206040c7bce00ce0102", "codeHash": "7dd2ed643a98b2a1a52a9b9e536fcdae60d961b583b8109f777d846bfdfcae8d", diff --git a/artifacts/sub/Sub.ral.json b/artifacts/sub/Sub.ral.json index 3e4f324ff..002f23247 100644 --- a/artifacts/sub/Sub.ral.json +++ b/artifacts/sub/Sub.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "Sub", "bytecode": "01011e01000202010dd321939f9e05160016015fa00016002a16012ba100a00002", "codeHash": "3461ebfaca02ad0a3f587a5b67a461c0cbd82d14261407b1d9277ed4ad129234", diff --git a/artifacts/test/Assert.ral.json b/artifacts/test/Assert.ral.json index f510249ee..6df5452a2 100644 --- a/artifacts/test/Assert.ral.json +++ b/artifacts/test/Assert.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "Assert", "bytecode": "000110010000000006d362d460120d0e2f0f7b", "codeHash": "46dc5e3835be6551dacbf81565912ec67575aa77522312ceed88472817735d6b", diff --git a/artifacts/test/CallScript0.ral.json b/artifacts/test/CallScript0.ral.json index 3e57ff0ce..29e77a721 100644 --- a/artifacts/test/CallScript0.ral.json +++ b/artifacts/test/CallScript0.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "CallScript0", "bytecodeTemplate": "01010000000206{1}0d0e{0}010302", "fieldsSig": { diff --git a/artifacts/test/CallScript1.ral.json b/artifacts/test/CallScript1.ral.json index 45e178c1d..8c39a2dc1 100644 --- a/artifacts/test/CallScript1.ral.json +++ b/artifacts/test/CallScript1.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "CallScript1", "bytecodeTemplate": "0101000000070a{1}0d0e{0}01030c11{2}010202", "fieldsSig": { diff --git a/artifacts/test/Debug.ral.json b/artifacts/test/Debug.ral.json index 6c23eeeee..5b7866138 100644 --- a/artifacts/test/Debug.ral.json +++ b/artifacts/test/Debug.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "Debug", "bytecode": "00010b010000000001d38681d619", "codeHash": "cc0e1966e6847f2c03384e78df1dcd9a0c2b5db1b7c1e901d66e26e2b000eb2c", diff --git a/artifacts/test/Deposit.ral.json b/artifacts/test/Deposit.ral.json index e474f2211..09a05094f 100644 --- a/artifacts/test/Deposit.ral.json +++ b/artifacts/test/Deposit.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "Deposit", "bytecodeTemplate": "01010300000007b413c40de0b6b3a7640000a20c0c{0}0100", "fieldsSig": { diff --git a/artifacts/test/DepositToken.ral.json b/artifacts/test/DepositToken.ral.json index 633a210db..abd7541db 100644 --- a/artifacts/test/DepositToken.ral.json +++ b/artifacts/test/DepositToken.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "DepositToken", "bytecodeTemplate": "01010300000009b4{1}{2}a3{2}0d0c{0}0102", "fieldsSig": { diff --git a/artifacts/test/InsertIntoMap.ral.json b/artifacts/test/InsertIntoMap.ral.json index 9a3897fd8..a345cdb52 100644 --- a/artifacts/test/InsertIntoMap.ral.json +++ b/artifacts/test/InsertIntoMap.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "InsertIntoMap", "bytecodeTemplate": "01010300020010{2}{3}17011700{1}d10f2ca2{1}160016010f0c{0}0100", "fieldsSig": { diff --git a/artifacts/test/MapTest.ral.json b/artifacts/test/MapTest.ral.json index 6d83d278b..7ae760aab 100644 --- a/artifacts/test/MapTest.ral.json +++ b/artifacts/test/MapTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "MapTest", "bytecode": "0004405c40dc4153418001030303001fd3a9cdcc691600d1a2140a5f5f6d61705f5f305f5f160047441601b11602d202011600d1a2140a5f5f6d61705f5f315f5f16014044b11602d201011600d1a2140a5f5f6d61705f5f325f5f1402001144b11602d2010101000104004036d3c50ed2bb0c0d0d140a5f5f6d61705f5f305f5f16004744cb1703160301000c0d0d160301011702170116020d2a0c0e0c140a5f5f6d61705f5f305f5f16004744cb010216020d2a0c0e0c140a5f5f6d61705f5f315f5f16014044cb010216020d2a0c0e0c140a5f5f6d61705f5f325f5f1402001144cb01020100010400402dd392ac08660c0d0d140a5f5f6d61705f5f305f5f16004744cb1703160301000c0d0d160301011702170116000d0c140a5f5f6d61705f5f305f5f16004744cb010316000d0c140a5f5f6d61705f5f315f5f16014044cb010316000d0c140a5f5f6d61705f5f325f5f1402001144cb0103010001020212d3143f7dc50c0d0d140a5f5f6d61705f5f305f5f16004744cb1701160101000c0d0d1601010102", "codeHash": "9c0dad73dd47255270a366794f84539f06816e30c68b1f1cca767707fa8db596", diff --git a/artifacts/test/MapTestWrapper.ral.json b/artifacts/test/MapTestWrapper.ral.json index ca2f20bb7..002180752 100644 --- a/artifacts/test/MapTestWrapper.ral.json +++ b/artifacts/test/MapTestWrapper.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "MapTestWrapper", "bytecode": "01031d4030404301030303000dd3a9cdcc691600d10f2ca21600160116020f0cce000100010001010006d3c50ed2bb16000d0cce000101010001010006d392ac086616000d0cce000102", "codeHash": "1d525d3e4cbd1c8f4c0431bf6881e888eeebae012a14532530097f62dd766e9a", diff --git a/artifacts/test/MetaData.ral.json b/artifacts/test/MetaData.ral.json index b8ae8d4da..eb38f7e90 100644 --- a/artifacts/test/MetaData.ral.json +++ b/artifacts/test/MetaData.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "MetaData", "bytecode": "000319402c4033010300000006d38d0b3636b4b413c40de0b6b3a7640000a702000200000004b413c40de0b6b3a7640000a80200000000000102", "codeHash": "5b113459525557465f1cc5aeee453dfd5823d1a6094372cee6067f7466b40896", diff --git a/artifacts/test/MultiDeposit.ral.json b/artifacts/test/MultiDeposit.ral.json index f510d3f7c..02815cc9b 100644 --- a/artifacts/test/MultiDeposit.ral.json +++ b/artifacts/test/MultiDeposit.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "MultiDeposit", "bytecodeTemplate": "0101030002004024{0}{1}17011700b413c40de0b6b3a7640000a20c0c16000100b413c40de0b6b3a7640000a20c0c16010100b4{2}13c40de0b6b3a7640000a313c40de0b6b3a76400000d0c16000102b4{2}13c40de0b6b3a7640000a313c40de0b6b3a76400000d0c16010102", "fieldsSig": { diff --git a/artifacts/test/MultiWithdraw.ral.json b/artifacts/test/MultiWithdraw.ral.json index 959b042ff..fb2f23ac7 100644 --- a/artifacts/test/MultiWithdraw.ral.json +++ b/artifacts/test/MultiWithdraw.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "MultiWithdraw", "bytecodeTemplate": "01010300020016{0}{1}170117000c0c160001010c0c1601010113c40de0b6b3a76400000d0c1600010313c40de0b6b3a76400000d0c16010103", "fieldsSig": { diff --git a/artifacts/test/OwnerOnly.ral.json b/artifacts/test/OwnerOnly.ral.json index ccd7724ff..578c0ef9e 100644 --- a/artifacts/test/OwnerOnly.ral.json +++ b/artifacts/test/OwnerOnly.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "OwnerOnly", "bytecode": "010111010000000006d3bf853dbdb4ce00450c7b", "codeHash": "c8ecfd7b7e1f3d0169d80e0abb59702516eeff301d47e0e7be70a631bd9414ca", diff --git a/artifacts/test/RemoveFromMap.ral.json b/artifacts/test/RemoveFromMap.ral.json index 1ed2e7c95..b8cbe826b 100644 --- a/artifacts/test/RemoveFromMap.ral.json +++ b/artifacts/test/RemoveFromMap.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "RemoveFromMap", "bytecodeTemplate": "01010300000005{1}0d0c{0}0102", "fieldsSig": { diff --git a/artifacts/test/TemplateArrayVar.ral.json b/artifacts/test/TemplateArrayVar.ral.json index ac32d6b6b..391c6795a 100644 --- a/artifacts/test/TemplateArrayVar.ral.json +++ b/artifacts/test/TemplateArrayVar.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "TemplateArrayVar", "bytecodeTemplate": "010103000e00408d{1}{2}{3}{4}1703170217011700{6}{7}{8}170617051704{0}18{5}1816030f2f16020e2f1a16010d2f1a16000c2f1a0c7b160016011708170716070c2f16080d2f1a0c7b16021603170a170916090e2f160a0f2f1a0c7b16060e2f16050d2f1a16040c2f1a0c7b0c170b160b0e314c40260c170c160c0e314c1b160b7a0e314d0e2c160c7a0e314d2a78160b0e2c160c2a2f0c7b160c0d2a170c4a21160b0d2a170b4a7fd60c170d160d0f314c11160d7a0f314d102a78160d2f0c7b160d0d2a170d4a2b", "fieldsSig": { diff --git a/artifacts/test/TestAssert.ral.json b/artifacts/test/TestAssert.ral.json index a972733ff..bedfc284f 100644 --- a/artifacts/test/TestAssert.ral.json +++ b/artifacts/test/TestAssert.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "TestAssert", "bytecodeTemplate": "010103000000040c0c{0}0100", "fieldsSig": { diff --git a/artifacts/test/Transact.ral.json b/artifacts/test/Transact.ral.json index 024ffbf16..c39b83b42 100644 --- a/artifacts/test/Transact.ral.json +++ b/artifacts/test/Transact.ral.json @@ -1,8 +1,8 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "Transact", - "bytecode": "03064027404e40674080408e409c010100010009d353dbb7aab413c40de0b6b3a7640000a9a00013c40de0b6b3a76400002aa10002010200010009d3a248861cb413c40de0b6b3a7640000a8a00013c40de0b6b3a76400002ba1000201010101000ad3bf2d01bdb4ce001600aca00116002aa1010201020101000ad35496306fb4ce001600aba00116002ba10102010000000103d3815a8d0da00002010000000103d3a51b051ca00102", - "codeHash": "85e3e9a803741af8e92bd43b1b07cde53f39b86cab0ef1a85bab12b10d691b55", + "bytecode": "03064027404e40674080408e409c010100000009d353dbb7aab413c40de0b6b3a7640000a9a00013c40de0b6b3a76400002aa10002010200000009d3a248861cb413c40de0b6b3a7640000a8a00013c40de0b6b3a76400002ba1000201010101000ad3bf2d01bdb4ce001600aca00116002aa1010201020101000ad35496306fb4ce001600aba00116002ba10102010000000103d3815a8d0da00002010000000103d3a51b051ca00102", + "codeHash": "0b6427253638fa8f32b04e7c5915d41d51b0148a8e219e4881eba5548a42ae41", "fieldsSig": { "names": [ "tokenId", diff --git a/artifacts/test/UpdateMapValue.ral.json b/artifacts/test/UpdateMapValue.ral.json index eea8763fb..667125fb9 100644 --- a/artifacts/test/UpdateMapValue.ral.json +++ b/artifacts/test/UpdateMapValue.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "UpdateMapValue", "bytecodeTemplate": "01010300000005{1}0d0c{0}0101", "fieldsSig": { diff --git a/artifacts/test/UpdateUserAccount.ral.json b/artifacts/test/UpdateUserAccount.ral.json index f48c512df..7a69d6049 100644 --- a/artifacts/test/UpdateUserAccount.ral.json +++ b/artifacts/test/UpdateUserAccount.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "UpdateUserAccount", "bytecodeTemplate": "01010300040015{1}{2}{3}{4}17031702170117001600160116021603100c{0}0100{5}0d0c{0}0101", "fieldsSig": { diff --git a/artifacts/test/UserAccount.ral.json b/artifacts/test/UserAccount.ral.json index f72145724..3e2b3cf12 100644 --- a/artifacts/test/UserAccount.ral.json +++ b/artifacts/test/UserAccount.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "UserAccount", "bytecode": "080340284037404d010004040013d388b067e71600ce01410c7b1602ce02410c7b1601a1021603a103160116032aa101010001010003d3185a39e11600a100010000000507d384cc0995a001ce01a002ce02a00302", "codeHash": "4e9f7eac1b76eaa2268b5af6ebb5640252892dc170aad6c1ee7b639131a55816", diff --git a/artifacts/test/Warnings.ral.json b/artifacts/test/Warnings.ral.json index 74f622e1a..19b0bcdcb 100644 --- a/artifacts/test/Warnings.ral.json +++ b/artifacts/test/Warnings.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "Warnings", "bytecode": "02010c010002020002d31bbce4a602", "codeHash": "873e095edb39cdb4b11b1157003daeacad06d259a938cd270e22b8e89b75feea", diff --git a/artifacts/test/Withdraw.ral.json b/artifacts/test/Withdraw.ral.json index 3f39517ad..ac63d65e6 100644 --- a/artifacts/test/Withdraw.ral.json +++ b/artifacts/test/Withdraw.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "Withdraw", "bytecodeTemplate": "010103000000040c0c{0}0101", "fieldsSig": { diff --git a/artifacts/token/FakeTokenTest.ral.json b/artifacts/token/FakeTokenTest.ral.json index 857b04aad..63b3678d6 100644 --- a/artifacts/token/FakeTokenTest.ral.json +++ b/artifacts/token/FakeTokenTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "FakeTokenTest", "bytecode": "010509121b4024402f010000000103044d18010000000103044d18010000000103044d18010000000103044d18010000000001d38d0b3636", "codeHash": "52f971cb44d54a5353e94dc8db991d2726f76760af782e79bd8a66a9b5b294b7", diff --git a/artifacts/token/TokenTest.ral.json b/artifacts/token/TokenTest.ral.json index e9146b952..417402fd2 100644 --- a/artifacts/token/TokenTest.ral.json +++ b/artifacts/token/TokenTest.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "TokenTest", "bytecode": "050409121b4024010000000102ce0002010000000102ce0102010000000102ce0202010000000102ce0302", "codeHash": "a2800413eb2c5c23d48068db23df5f8eeaba04653e12c8ed59d589720d96dadd", diff --git a/artifacts/token/TokenTestStd.ral.json b/artifacts/token/TokenTestStd.ral.json index 5fb8ce858..d6cacb113 100644 --- a/artifacts/token/TokenTestStd.ral.json +++ b/artifacts/token/TokenTestStd.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.9.1", + "version": "v3.10.0", "name": "TokenTestStd", "bytecode": "050509121b40244030010000000102ce0002010000000102ce0102010000000102ce0202010000000102ce0302010000000002d36811cfdd02", "codeHash": "4aa5c769148cada8eeb1cd3791f6e793ed92009ac79ebb64dc79d4d7f2969c8b", diff --git a/artifacts/ts/Add.ts b/artifacts/ts/Add.ts index 99b08eb44..50b277267 100644 --- a/artifacts/ts/Add.ts +++ b/artifacts/ts/Add.ts @@ -252,7 +252,7 @@ export const Add = new Factory( Contract.fromJson( AddContractJson, "=12-2+5c=2-2+81=3-1+e=2-2+bc=83-1+97e010a61646450726976617465=266", - "c46db1ae7bae8b332c115869126eb1402bc71574925608a2adcea3cf7b9f8e7e", + "c8b4522606d53c50b6ff00009a5072ceba32fd8de32b77033e8d74500ccba6d3", AllStructs ) ); diff --git a/artifacts/ts/Transact.ts b/artifacts/ts/Transact.ts index 918d4f718..89d948cbf 100644 --- a/artifacts/ts/Transact.ts +++ b/artifacts/ts/Transact.ts @@ -206,7 +206,7 @@ export const Transact = new Factory( Contract.fromJson( TransactContractJson, "", - "85e3e9a803741af8e92bd43b1b07cde53f39b86cab0ef1a85bab12b10d691b55", + "0b6427253638fa8f32b04e7c5915d41d51b0148a8e219e4881eba5548a42ae41", AllStructs ) ); diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index d298a0fc5..ea822a3d0 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -29,7 +29,7 @@ services: condition: service_healthy alephium: - image: alephium/alephium:v3.9.1 + image: alephium/alephium:v3.10.0 restart: unless-stopped ports: - 19973:19973/tcp diff --git a/packages/web3/package.json b/packages/web3/package.json index 43e55cbac..daa6c0ea6 100644 --- a/packages/web3/package.json +++ b/packages/web3/package.json @@ -33,7 +33,7 @@ }, "author": "Alephium dev ", "config": { - "alephium_version": "3.9.1", + "alephium_version": "3.10.0", "explorer_backend_version": "2.3.2" }, "scripts": { diff --git a/packages/web3/src/api/api-alephium.ts b/packages/web3/src/api/api-alephium.ts index bdfb5e2e6..3c311199c 100644 --- a/packages/web3/src/api/api-alephium.ts +++ b/packages/web3/src/api/api-alephium.ts @@ -367,6 +367,8 @@ export interface BuildSweepAddressTransactions { gasPrice?: string /** @format block-hash */ targetBlockHash?: string + /** @format int32 */ + utxosLimit?: number } /** BuildSweepAddressTransactionsResult */ @@ -1647,7 +1649,7 @@ export class HttpClient { /** * @title Alephium API - * @version 3.9.1 + * @version 3.10.0 * @baseUrl ../ */ export class Api extends HttpClient { From 617fdd122a96af052a7bdec437c4a46c380fd5e7 Mon Sep 17 00:00:00 2001 From: lbqds Date: Fri, 13 Dec 2024 09:16:58 +0800 Subject: [PATCH 2/3] Support testing of inline functions --- .project.json | 6 + artifacts/test/InlineTest.ral.json | 49 +++++ artifacts/ts/InlineTest.ts | 262 +++++++++++++++++++++++++ artifacts/ts/index.ts | 1 + contracts/test/inline.ral | 21 ++ packages/web3/src/contract/contract.ts | 36 +++- test/contract.test.ts | 82 +++++++- 7 files changed, 440 insertions(+), 17 deletions(-) create mode 100644 artifacts/test/InlineTest.ral.json create mode 100644 artifacts/ts/InlineTest.ts create mode 100644 contracts/test/inline.ral diff --git a/.project.json b/.project.json index 6eb72af13..ee722edf2 100644 --- a/.project.json +++ b/.project.json @@ -191,6 +191,12 @@ "bytecodeDebugPatch": "", "codeHashDebug": "" }, + "InlineTest": { + "sourceFile": "test/inline.ral", + "sourceCodeHash": "6b4523198ea38cb62ec306413c52aef1e77f85e0e845cbed7a8dedae246df01f", + "bytecodeDebugPatch": "=3-1+3=4+40454054=86+000100000109b413c32386f26fc10000a9a0000d2aa100a00002000000000106a0000d2aa100a00002", + "codeHashDebug": "f8d74ceeaa346ad74b340afb8b1ddf6be2e5a90384561b03f0b7161dd0e45b12" + }, "InsertIntoMap": { "sourceFile": "test/map.ral", "sourceCodeHash": "331b92fe6617c1c7ac7f742ceea1943a06717477a2bd03ca266d23c65d844de6", diff --git a/artifacts/test/InlineTest.ral.json b/artifacts/test/InlineTest.ral.json new file mode 100644 index 000000000..7cb8debab --- /dev/null +++ b/artifacts/test/InlineTest.ral.json @@ -0,0 +1,49 @@ +{ + "version": "v3.10.0", + "name": "InlineTest", + "bytecode": "0101402b010100000112d3811965ccb413c32386f26fc10000a9a0000d2aa100a00018a0000d2aa100a00018a00002", + "codeHash": "5ce5376e13ecf0b46e03923f50782b844e8bb099c8d3ab2cf6d8d3484c9150ed", + "fieldsSig": { + "names": [ + "count" + ], + "types": [ + "U256" + ], + "isMutable": [ + true + ] + }, + "eventsSig": [], + "functions": [ + { + "name": "nextCount", + "paramNames": [], + "paramTypes": [], + "paramIsMutable": [], + "returnTypes": [ + "U256" + ] + }, + { + "name": "nextCountWithPay", + "paramNames": [], + "paramTypes": [], + "paramIsMutable": [], + "returnTypes": [ + "U256" + ] + }, + { + "name": "nextCountWithoutPay", + "paramNames": [], + "paramTypes": [], + "paramIsMutable": [], + "returnTypes": [ + "U256" + ] + } + ], + "constants": [], + "enums": [] +} \ No newline at end of file diff --git a/artifacts/ts/InlineTest.ts b/artifacts/ts/InlineTest.ts new file mode 100644 index 000000000..09817aec4 --- /dev/null +++ b/artifacts/ts/InlineTest.ts @@ -0,0 +1,262 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { + Address, + Contract, + ContractState, + TestContractResult, + HexString, + ContractFactory, + EventSubscribeOptions, + EventSubscription, + CallContractParams, + CallContractResult, + TestContractParams, + ContractEvent, + subscribeContractEvent, + subscribeContractEvents, + testMethod, + callMethod, + multicallMethods, + fetchContractState, + Asset, + ContractInstance, + getContractEventsCurrentCount, + TestContractParamsWithoutMaps, + TestContractResultWithoutMaps, + SignExecuteContractMethodParams, + SignExecuteScriptTxResult, + signExecuteMethod, + addStdIdToFields, + encodeContractFields, + Narrow, +} from "@alephium/web3"; +import { default as InlineTestContractJson } from "../test/InlineTest.ral.json"; +import { getContractByCodeHash, registerContract } from "./contracts"; +import { + AddStruct1, + AddStruct2, + Balances, + MapValue, + TokenBalance, + AllStructs, +} from "./types"; + +// Custom types for the contract +export namespace InlineTestTypes { + export type Fields = { + count: bigint; + }; + + export type State = ContractState; + + export interface CallMethodTable { + nextCount: { + params: Omit, "args">; + result: CallContractResult; + }; + nextCountWithPay: { + params: Omit, "args">; + result: CallContractResult; + }; + nextCountWithoutPay: { + params: Omit, "args">; + result: CallContractResult; + }; + } + export type CallMethodParams = + CallMethodTable[T]["params"]; + export type CallMethodResult = + CallMethodTable[T]["result"]; + export type MultiCallParams = Partial<{ + [Name in keyof CallMethodTable]: CallMethodTable[Name]["params"]; + }>; + export type MultiCallResults = { + [MaybeName in keyof T]: MaybeName extends keyof CallMethodTable + ? CallMethodTable[MaybeName]["result"] + : undefined; + }; + export type MulticallReturnType = { + [index in keyof Callss]: MultiCallResults; + }; + + export interface SignExecuteMethodTable { + nextCount: { + params: Omit, "args">; + result: SignExecuteScriptTxResult; + }; + nextCountWithPay: { + params: Omit, "args">; + result: SignExecuteScriptTxResult; + }; + nextCountWithoutPay: { + params: Omit, "args">; + result: SignExecuteScriptTxResult; + }; + } + export type SignExecuteMethodParams = + SignExecuteMethodTable[T]["params"]; + export type SignExecuteMethodResult = + SignExecuteMethodTable[T]["result"]; +} + +class Factory extends ContractFactory< + InlineTestInstance, + InlineTestTypes.Fields +> { + encodeFields(fields: InlineTestTypes.Fields) { + return encodeContractFields( + addStdIdToFields(this.contract, fields), + this.contract.fieldsSig, + AllStructs + ); + } + + at(address: string): InlineTestInstance { + return new InlineTestInstance(address); + } + + tests = { + nextCount: async ( + params: Omit< + TestContractParamsWithoutMaps, + "testArgs" + > + ): Promise> => { + return testMethod(this, "nextCount", params, getContractByCodeHash); + }, + nextCountWithPay: async ( + params: Omit< + TestContractParamsWithoutMaps, + "testArgs" + > + ): Promise> => { + return testMethod( + this, + "nextCountWithPay", + params, + getContractByCodeHash + ); + }, + nextCountWithoutPay: async ( + params: Omit< + TestContractParamsWithoutMaps, + "testArgs" + > + ): Promise> => { + return testMethod( + this, + "nextCountWithoutPay", + params, + getContractByCodeHash + ); + }, + }; + + stateForTest( + initFields: InlineTestTypes.Fields, + asset?: Asset, + address?: string + ) { + return this.stateForTest_(initFields, asset, address, undefined); + } +} + +// Use this object to test and deploy the contract +export const InlineTest = new Factory( + Contract.fromJson( + InlineTestContractJson, + "=3-1+3=4+40454054=86+000100000109b413c32386f26fc10000a9a0000d2aa100a00002000000000106a0000d2aa100a00002", + "f8d74ceeaa346ad74b340afb8b1ddf6be2e5a90384561b03f0b7161dd0e45b12", + AllStructs + ) +); +registerContract(InlineTest); + +// Use this class to interact with the blockchain +export class InlineTestInstance extends ContractInstance { + constructor(address: Address) { + super(address); + } + + async fetchState(): Promise { + return fetchContractState(InlineTest, this); + } + + view = { + nextCount: async ( + params?: InlineTestTypes.CallMethodParams<"nextCount"> + ): Promise> => { + return callMethod( + InlineTest, + this, + "nextCount", + params === undefined ? {} : params, + getContractByCodeHash + ); + }, + nextCountWithPay: async ( + params?: InlineTestTypes.CallMethodParams<"nextCountWithPay"> + ): Promise> => { + return callMethod( + InlineTest, + this, + "nextCountWithPay", + params === undefined ? {} : params, + getContractByCodeHash + ); + }, + nextCountWithoutPay: async ( + params?: InlineTestTypes.CallMethodParams<"nextCountWithoutPay"> + ): Promise> => { + return callMethod( + InlineTest, + this, + "nextCountWithoutPay", + params === undefined ? {} : params, + getContractByCodeHash + ); + }, + }; + + transact = { + nextCount: async ( + params: InlineTestTypes.SignExecuteMethodParams<"nextCount"> + ): Promise> => { + return signExecuteMethod(InlineTest, this, "nextCount", params); + }, + nextCountWithPay: async ( + params: InlineTestTypes.SignExecuteMethodParams<"nextCountWithPay"> + ): Promise> => { + return signExecuteMethod(InlineTest, this, "nextCountWithPay", params); + }, + nextCountWithoutPay: async ( + params: InlineTestTypes.SignExecuteMethodParams<"nextCountWithoutPay"> + ): Promise< + InlineTestTypes.SignExecuteMethodResult<"nextCountWithoutPay"> + > => { + return signExecuteMethod(InlineTest, this, "nextCountWithoutPay", params); + }, + }; + + async multicall( + calls: Calls + ): Promise>; + async multicall( + callss: Narrow + ): Promise>; + async multicall< + Callss extends + | InlineTestTypes.MultiCallParams + | InlineTestTypes.MultiCallParams[] + >(callss: Callss): Promise { + return await multicallMethods( + InlineTest, + this, + callss, + getContractByCodeHash + ); + } +} diff --git a/artifacts/ts/index.ts b/artifacts/ts/index.ts index 8b6d37e91..4dd5644d2 100644 --- a/artifacts/ts/index.ts +++ b/artifacts/ts/index.ts @@ -14,6 +14,7 @@ export * from "./DeprecatedNFTTest6"; export * from "./DeprecatedNFTTest7"; export * from "./FakeTokenTest"; export * from "./Greeter"; +export * from "./InlineTest"; export * from "./MapTest"; export * from "./MapTestWrapper"; export * from "./MetaData"; diff --git a/contracts/test/inline.ral b/contracts/test/inline.ral new file mode 100644 index 000000000..cb0d7f7b3 --- /dev/null +++ b/contracts/test/inline.ral @@ -0,0 +1,21 @@ +Contract InlineTest(mut count: U256) { + @using(updateFields = true, assetsInContract = true, preapprovedAssets = true) + @inline fn nextCountWithPay() -> U256 { + transferTokenToSelf!(callerAddress!(), ALPH, 0.01 alph) + count = count + 1 + return count + } + + @using(updateFields = true) + @inline fn nextCountWithoutPay() -> U256 { + count = count + 1 + return count + } + + @using(checkExternalCaller = false, preapprovedAssets = true) + pub fn nextCount() -> U256 { + let _ = nextCountWithPay{callerAddress!() -> ALPH: 0.01 alph}() + let _ = nextCountWithoutPay() + return count + } +} \ No newline at end of file diff --git a/packages/web3/src/contract/contract.ts b/packages/web3/src/contract/contract.ts index e1e921d71..95a2c7d32 100644 --- a/packages/web3/src/contract/contract.ts +++ b/packages/web3/src/contract/contract.ts @@ -204,6 +204,7 @@ export class Contract extends Artifact { readonly decodedContract: contract.Contract private bytecodeForTesting: string | undefined + private decodedTestingContract: contract.Contract | undefined private codeHashForTesting: string | undefined constructor( @@ -239,13 +240,23 @@ export class Contract extends Artifact { this.decodedContract = contract.contractCodec.decodeContract(hexToBinUnsafe(this.bytecode)) this.bytecodeForTesting = undefined + this.decodedTestingContract = undefined this.codeHashForTesting = undefined } + isInlineFunc(index: number): boolean { + if (index >= this.functions.length) { + throw new Error(`Invalid function index ${index}, function size: ${this.functions.length}`) + } + const inlineFuncFromIndex = this.decodedContract.methods.length + return index >= inlineFuncFromIndex + } + getByteCodeForTesting(): string { if (this.bytecodeForTesting !== undefined) return this.bytecodeForTesting - if (this.publicFunctions().length == this.functions.length) { + const hasInlineFunction = this.functions.length > this.decodedContract.methods.length + if (!hasInlineFunction && this.publicFunctions().length == this.functions.length) { this.bytecodeForTesting = this.bytecodeDebug this.codeHashForTesting = this.codeHashDebug return this.bytecodeForTesting @@ -263,6 +274,13 @@ export class Contract extends Artifact { return this.bytecodeForTesting } + getDecodedTestingContract() { + if (this.decodedTestingContract !== undefined) return this.decodedTestingContract + const bytecodeForTesting = hexToBinUnsafe(this.getByteCodeForTesting()) + this.decodedTestingContract = contract.contractCodec.decodeContract(bytecodeForTesting) + return this.decodedTestingContract + } + hasCodeHash(hash: string): boolean { return this.codeHash === hash || this.codeHashDebug === hash || this.codeHashForTesting === hash } @@ -283,8 +301,10 @@ export class Contract extends Artifact { return this.functions.filter((_, index) => this.getDecodedMethod(index).useContractAssets) } - isMethodUsePreapprovedAssets(methodIndex: number): boolean { - return this.getDecodedMethod(methodIndex).usePreapprovedAssets + isMethodUsePreapprovedAssets(isDevnet: boolean, methodIndex: number): boolean { + if (!isDevnet || !this.isInlineFunc(methodIndex)) return this.getDecodedMethod(methodIndex).usePreapprovedAssets + const contract = this.getDecodedTestingContract() + return contract.methods[`${methodIndex}`].usePreapprovedAssets } // TODO: safely parse json @@ -455,6 +475,7 @@ export class Contract extends Artifact { ) const immFields = allFields.filter((f) => !f.isMutable).map((f) => toApiVal(f.value, f.type)) const mutFields = allFields.filter((f) => f.isMutable).map((f) => toApiVal(f.value, f.type)) + const methodIndex = this.getMethodIndex(funcName) return { group: params.group, blockHash: params.blockHash, @@ -462,11 +483,11 @@ export class Contract extends Artifact { txId: params.txId, address: params.address, callerAddress: params.callerAddress, - bytecode: this.bytecodeDebug, + bytecode: this.isInlineFunc(methodIndex) ? this.getByteCodeForTesting() : this.bytecodeDebug, initialImmFields: immFields, initialMutFields: mutFields, initialAsset: typeof params.initialAsset !== 'undefined' ? toApiAsset(params.initialAsset) : undefined, - methodIndex: this.getMethodIndex(funcName), + methodIndex, args: this.toApiArgs(funcName, params.testArgs), existingContracts: this.toApiContractStates(params.existingContracts), inputAssets: toApiInputAssets(params.inputAssets) @@ -1851,7 +1872,8 @@ export async function signExecuteMethod { const methodIndex = contract.contract.getMethodIndex(methodName) const functionSig = contract.contract.functions[methodIndex] - const methodUsePreapprovedAssets = contract.contract.isMethodUsePreapprovedAssets(methodIndex) + const isDevnet = await contract.contract.isDevnet(params.signer) + const methodUsePreapprovedAssets = contract.contract.isMethodUsePreapprovedAssets(isDevnet, methodIndex) const bytecodeTemplate = getBytecodeTemplate( methodIndex, methodUsePreapprovedAssets, @@ -1882,7 +1904,7 @@ export async function signExecuteMethod { const sourceFiles = await Project['loadSourceFiles']('.', './contracts') // `loadSourceFiles` is a private method - expect(sourceFiles.length).toEqual(60) - sourceFiles.slice(0, 27).forEach((c) => expect(c.type).toEqual(0)) // contracts - sourceFiles.slice(27, 45).forEach((s) => expect(s.type).toEqual(1)) // scripts - sourceFiles.slice(45, 47).forEach((i) => expect(i.type).toEqual(2)) // abstract class - sourceFiles.slice(47, 54).forEach((i) => expect(i.type).toEqual(3)) // interfaces - sourceFiles.slice(54, 59).forEach((i) => expect(i.type).toEqual(4)) // structs - expect(sourceFiles[59].type).toEqual(5) // constants + expect(sourceFiles.length).toEqual(61) + sourceFiles.slice(0, 28).forEach((c) => expect(c.type).toEqual(0)) // contracts + sourceFiles.slice(28, 46).forEach((s) => expect(s.type).toEqual(1)) // scripts + sourceFiles.slice(46, 48).forEach((i) => expect(i.type).toEqual(2)) // abstract class + sourceFiles.slice(48, 55).forEach((i) => expect(i.type).toEqual(3)) // interfaces + sourceFiles.slice(58, 60).forEach((i) => expect(i.type).toEqual(4)) // structs + expect(sourceFiles[60].type).toEqual(5) // constants }) it('should load contract from json', () => { @@ -895,4 +902,59 @@ describe('contract', function () { const notExist = await getContractCodeByCodeHash(nodeProvider, randomHash) expect(notExist).toEqual(undefined) }) + + it('should test inline functions(unit test)', async () => { + const contractAddress = randomContractAddress() + const result0 = await InlineTest.tests.nextCountWithPay({ + address: contractAddress, + initialFields: { count: 0n }, + inputAssets: [{ address: signer.address, asset: { alphAmount: ONE_ALPH } }], + initialAsset: { alphAmount: ONE_ALPH } + }) + expect(result0.returns).toEqual(1n) + const assets0 = result0.contracts.find((c) => c.address === contractAddress)!.asset + expect(assets0.alphAmount).toEqual(ONE_ALPH + ONE_ALPH / 100n) + + const result1 = await InlineTest.tests.nextCountWithoutPay({ + address: contractAddress, + initialFields: { count: 0n }, + initialAsset: { alphAmount: ONE_ALPH } + }) + expect(result1.returns).toEqual(1n) + const assets1 = result1.contracts.find((c) => c.address === contractAddress)!.asset + expect(assets1.alphAmount).toEqual(ONE_ALPH) + + const result2 = await InlineTest.tests.nextCount({ + address: contractAddress, + initialFields: { count: 0n }, + inputAssets: [{ address: signer.address, asset: { alphAmount: ONE_ALPH } }], + initialAsset: { alphAmount: ONE_ALPH } + }) + expect(result2.returns).toEqual(2n) + const assets2 = result2.contracts.find((c) => c.address === contractAddress)!.asset + expect(assets2.alphAmount).toEqual(ONE_ALPH + ONE_ALPH / 100n) + }) + + it('should test inline functions(integration test)', async () => { + const deployResult0 = await InlineTest.deploy(signer, { + initialFields: { count: 0n }, + initialAttoAlphAmount: ONE_ALPH, + exposePrivateFunctions: true + }) + const instance = deployResult0.contractInstance + await instance.transact.nextCountWithPay({ signer, attoAlphAmount: ONE_ALPH }) + const state0 = await instance.fetchState() + expect(state0.fields.count).toEqual(1n) + expect(state0.asset.alphAmount).toEqual(ONE_ALPH + ONE_ALPH / 100n) + + await instance.transact.nextCountWithoutPay({ signer }) + const state1 = await instance.fetchState() + expect(state1.fields.count).toEqual(2n) + expect(state1.asset.alphAmount).toEqual(ONE_ALPH + ONE_ALPH / 100n) + + await instance.transact.nextCount({ signer, attoAlphAmount: ONE_ALPH }) + const state2 = await instance.fetchState() + expect(state2.fields.count).toEqual(4n) + expect(state2.asset.alphAmount).toEqual(ONE_ALPH + (ONE_ALPH / 100n) * 2n) + }) }) From 7138dfde1360c49fea616466843150d638cfce46 Mon Sep 17 00:00:00 2001 From: lbqds Date: Fri, 13 Dec 2024 09:39:14 +0800 Subject: [PATCH 3/3] Fix event subscription --- packages/web3/src/contract/events.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/web3/src/contract/events.ts b/packages/web3/src/contract/events.ts index 472a0c600..2bb065d0a 100644 --- a/packages/web3/src/contract/events.ts +++ b/packages/web3/src/contract/events.ts @@ -19,6 +19,7 @@ along with the library. If not, see . import * as web3 from '../global' import { node } from '../api' import { Subscription, SubscribeOptions } from '../utils' +import { ContractEvents } from '../api/api-alephium' export interface EventSubscribeOptions extends SubscribeOptions { onEventCountChanged?: (eventCount: number) => Promise | void @@ -40,11 +41,22 @@ export class EventSubscription extends Subscription { return this.fromCount } + private async getEvents(start: number): Promise { + try { + return await web3 + .getCurrentNodeProvider() + .events.getEventsContractContractaddress(this.contractAddress, { start }) + } catch (error) { + if (error instanceof Error && error.message.includes(`Contract events of ${this.contractAddress} not found`)) { + return { events: [], nextStart: start } + } + throw error + } + } + override async polling(): Promise { try { - const events = await web3.getCurrentNodeProvider().events.getEventsContractContractaddress(this.contractAddress, { - start: this.fromCount - }) + const events = await this.getEvents(this.fromCount) if (this.fromCount === events.nextStart) { return }