From 344a4e200711d5b3c218e0e63796977868208051 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Wed, 13 Nov 2024 11:45:17 +0100 Subject: [PATCH 01/14] Add piggy-bank example --- .../rpc/examples/js/contracts/PiggyBank.sol | 29 ++++++++++ .../revive/rpc/examples/js/evm-contracts.json | 57 ++++++++++++++++++- .../revive/rpc/examples/js/pvm-contracts.json | 55 ++++++++++++++++++ .../rpc/examples/js/src/build-contracts.ts | 1 + .../revive/rpc/examples/js/src/piggy-bank.ts | 17 ++++++ substrate/frame/revive/src/lib.rs | 15 ++++- 6 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 substrate/frame/revive/rpc/examples/js/contracts/PiggyBank.sol create mode 100644 substrate/frame/revive/rpc/examples/js/src/piggy-bank.ts diff --git a/substrate/frame/revive/rpc/examples/js/contracts/PiggyBank.sol b/substrate/frame/revive/rpc/examples/js/contracts/PiggyBank.sol new file mode 100644 index 000000000000..82373e8b9207 --- /dev/null +++ b/substrate/frame/revive/rpc/examples/js/contracts/PiggyBank.sol @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +contract PiggyBank { + + uint private balance; + address public owner; + + constructor() { + owner = msg.sender; + balance = 0; + } + + function deposit() public payable returns (uint) { + balance += msg.value; + return balance; + } + + function withdraw(uint withdrawAmount) public returns (uint remainingBal) { + require(msg.sender == owner); + balance -= withdrawAmount; + // Use call to transfer Ether + (bool success, ) = payable(msg.sender).call{value: withdrawAmount}(""); + require(success, "Transfer failed"); + + return balance; + } +} + diff --git a/substrate/frame/revive/rpc/examples/js/evm-contracts.json b/substrate/frame/revive/rpc/examples/js/evm-contracts.json index 4d98f5dd8149..f01afbac4be1 100644 --- a/substrate/frame/revive/rpc/examples/js/evm-contracts.json +++ b/substrate/frame/revive/rpc/examples/js/evm-contracts.json @@ -34,7 +34,7 @@ "type": "function" } ], - "bytecode": "6080604052348015600e575f5ffd5b506101b68061001c5f395ff3fe608060405234801561000f575f5ffd5b5060043610610029575f3560e01c8063ede48fb71461002d575b5f5ffd5b610035610037565b005b5f61303990505f6040518060400160405280600b81526020017f48656c6c6f20776f726c6400000000000000000000000000000000000000000081525090503373ffffffffffffffffffffffffffffffffffffffff167f1585375487296ff2f0370daeec4214074a032b31af827c12622fa9a58c16c7d083836040516100be929190610152565b60405180910390a25050565b5f819050919050565b6100dc816100ca565b82525050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f601f19601f8301169050919050565b5f610124826100e2565b61012e81856100ec565b935061013e8185602086016100fc565b6101478161010a565b840191505092915050565b5f6040820190506101655f8301856100d3565b8181036020830152610177818461011a565b9050939250505056fea2646970667358221220a159f2cdba512e018377f5822cfd8ef04769755d98c3e494275605d96d7d13e864736f6c634300081c0033" + "bytecode": "6080604052348015600e575f5ffd5b506101b68061001c5f395ff3fe608060405234801561000f575f5ffd5b5060043610610029575f3560e01c8063ede48fb71461002d575b5f5ffd5b610035610037565b005b5f61303990505f6040518060400160405280600b81526020017f48656c6c6f20776f726c6400000000000000000000000000000000000000000081525090503373ffffffffffffffffffffffffffffffffffffffff167f1585375487296ff2f0370daeec4214074a032b31af827c12622fa9a58c16c7d083836040516100be929190610152565b60405180910390a25050565b5f819050919050565b6100dc816100ca565b82525050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f601f19601f8301169050919050565b5f610124826100e2565b61012e81856100ec565b935061013e8185602086016100fc565b6101478161010a565b840191505092915050565b5f6040820190506101655f8301856100d3565b8181036020830152610177818461011a565b9050939250505056fea2646970667358221220733c01f3a7c5f2cc4a2926b236ca12c75e1a5b640aaa4e7998fffa79ebddd15264736f6c634300081c0033" }, "revert": { "abi": [ @@ -52,5 +52,60 @@ } ], "bytecode": "6080604052348015600e575f5ffd5b506101138061001c5f395ff3fe6080604052348015600e575f5ffd5b50600436106026575f3560e01c8063afc874d214602a575b5f5ffd5b60306032565b005b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040160629060c1565b60405180910390fd5b5f82825260208201905092915050565b7f726576657274206d6573736167650000000000000000000000000000000000005f82015250565b5f60ad600e83606b565b915060b682607b565b602082019050919050565b5f6020820190508181035f83015260d68160a3565b905091905056fea264697066735822122084f7096e030faf779d12b20184187708d335e4bcd4208a52c0651700fe8dde6a64736f6c634300081c0033" + }, + "piggyBank": { + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "deposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "withdrawAmount", + "type": "uint256" + } + ], + "name": "withdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "remainingBal", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "6080604052348015600e575f5ffd5b503360015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505f5f81905550610485806100625f395ff3fe608060405260043610610033575f3560e01c80632e1a7d4d146100375780638da5cb5b14610073578063d0e30db01461009d575b5f5ffd5b348015610042575f5ffd5b5061005d60048036038101906100589190610258565b6100bb565b60405161006a9190610292565b60405180910390f35b34801561007e575f5ffd5b506100876101dd565b60405161009491906102ea565b60405180910390f35b6100a5610202565b6040516100b29190610292565b60405180910390f35b5f60015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610114575f5ffd5b815f5f8282546101249190610330565b925050819055505f3373ffffffffffffffffffffffffffffffffffffffff168360405161015090610390565b5f6040518083038185875af1925050503d805f811461018a576040519150601f19603f3d011682016040523d82523d5f602084013e61018f565b606091505b50509050806101d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101ca906103fe565b60405180910390fd5b5f54915050919050565b60015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b5f345f5f828254610213919061041c565b925050819055505f54905090565b5f5ffd5b5f819050919050565b61023781610225565b8114610241575f5ffd5b50565b5f813590506102528161022e565b92915050565b5f6020828403121561026d5761026c610221565b5b5f61027a84828501610244565b91505092915050565b61028c81610225565b82525050565b5f6020820190506102a55f830184610283565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6102d4826102ab565b9050919050565b6102e4816102ca565b82525050565b5f6020820190506102fd5f8301846102db565b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f61033a82610225565b915061034583610225565b925082820390508181111561035d5761035c610303565b5b92915050565b5f81905092915050565b50565b5f61037b5f83610363565b91506103868261036d565b5f82019050919050565b5f61039a82610370565b9150819050919050565b5f82825260208201905092915050565b7f5472616e73666572206661696c656400000000000000000000000000000000005f82015250565b5f6103e8600f836103a4565b91506103f3826103b4565b602082019050919050565b5f6020820190508181035f830152610415816103dc565b9050919050565b5f61042682610225565b915061043183610225565b925082820190508082111561044957610448610303565b5b9291505056fea26469706673582212208a6ff34375d5ce1478762d3d03a5f0cd133d32391f8da467fd2cb37790eaba3664736f6c634300081c0033" } } \ No newline at end of file diff --git a/substrate/frame/revive/rpc/examples/js/pvm-contracts.json b/substrate/frame/revive/rpc/examples/js/pvm-contracts.json index be58e88a9a63..ac36048f114c 100644 --- a/substrate/frame/revive/rpc/examples/js/pvm-contracts.json +++ b/substrate/frame/revive/rpc/examples/js/pvm-contracts.json @@ -52,5 +52,60 @@ } ], "bytecode": "50564d0001ba09000000000000010700c13004c0004004440400000000050000001000000022000000696e7075747365616c5f72657475726e7365745f696d6d757461626c655f6461746176616c75655f7472616e7366657272656405110288020463616c6c8809066465706c6f79068947170288126700aa00af00ce006901a802c502e102f5021303ab04c604cf04eb043d06d50632078f07c907dc07ea070908110852790e7a1004070f0a41040a0000012f8a3908890802871f1277e03b370000010a040713000a0800000229781416070000025278040710000208870713000407100002088707130013000211e003101c0315180316140215201211e0127601040704080610029d16070400020d010004040710000352184e11011726032c040326032804032603240403260320040326031c0403260318040326031404031607100403070607061004090610064b020211c003103c0315380316340215401211e0521604074004082006100837ff07071602040804000226036000020000008026035c000226035800022603540002260350000226034c0002260348000203681826034400020217e01277e003671c52710d171c0d17180d17140d17100d170c0d17080d17040d074e031101681c0182100183018914018a1c018b0c018c040187180188080cba0a0cc9090ca9090c87070c23080c87070c97070f077e0104074004082006100a9cfe07077b01016718017450017040017b58017c48017a5401724c0173440e2808128800ff000e29180c9808122900ff000999080922180c92090c980803681c0e3808128800ff000e39180c9808123900ff000999080933180c93090c89030ea808128800ff000ea9180c980812a900ff0009990809aa180ca9090c89020ec808128800ff000ec9180c980812c900ff0009990809cc180cc9090c890c0eb808128800ff000eb9180c980812b900ff0009990809bb180cb9090c98080e0908129900ff000e0b180cb909120b00ff0009bb080900180cb00b0cb9090e4b0812bb00ff000e4a180cba0a124b00ff0009bb080944180cb40b0cba0a0ca9090cc8080c98080c3209016a1c0ca9090c98080f086e01681801885c0e8908129900ff000e8a180ca909128700ff000977080988180c87070c970703671c040806100c5dfd07073c0a0808000207080b04073004034e021101671c040806100e40fd07071f01681801671c087808040704094e01110407040806101024fd0f070400040804000204070104090400124e011102118003107c031578031674021580001211e0040740040820061014f2fc0f07040004061004030a0710040303173c0a041404030a031804030a092c04030a082804030a002004030a0c2404032797278a54970a27cb270754cb070c980b54ba070316380a0b1c04032742011a3c1baa041faa0154420a27b2273654b2060cb30b54b60a0cc9090c80080c980854870a040904000226036000020000008026035c000226035800022603540002260350000226034c000226034800022603440002070a0b010a071000030f47afc874d2020103193c0d115c0d11580d11540d11500d114c0d11480d11440d11400217404e0311011250011840011954011a5c011b4c011c440116580117480cba0a0cc9090ca9090c67070c28080c87070c97070f07b10001173801721c017318017414017a100178017c0c017604017708028bfc248b0808860b02bbff1c6b09246b0b53980b0278ff08b8092479002489081b7601146c060868081cc80624c8085360081c97070c6707537b0802a7ff0878082478071ba8011484080878092489085377080c4a071b77011473090898082498082473071472070887072d0741040704080610165afb07076bfe040804000204070104094e01040018051e030610181b030407040806101a36fb070747fe040804000204070104094e011104074004082006101c1afb07072bfe01103c010250010340010458010b48010c54010a4c0108440ea608126600ff000ea9180c690912a600ff0009660809aa180c6a0a0ca9090319380e8908129900ff000e8a180ca909128a00ff0009aa080988180ca8080c98080318340ec808128800ff000ec9180c980812c900ff0009990809cc180cc9090c890c0eb808128800ff000eb9180c980812b900ff0009990809bb180cb9090c890a0e4808128800ff000e49180c9808124900ff000999080944180c94090c89040e3808128800ff000e39180c9808123900ff000999080933180c93090c89030e2808128800ff000e29180c9808122900ff000999080922180c92060c860b0c3b080ca4090c98080119340cc9090116380c69090c98080f0818fd52b6031320031a24031c2803142c01085c0e8908129900ff000e8a180ca909128700ff000977080988180c87070c970704082003173006101ec8f90707d9fc011230011a3c082a0a0d0a08c379a00113382737011424274b53470b011c3427c701182027895387090c8c07537b09011b2827b727605367000cb6060cc3070d1a1c0d1a180d1a140d1a100d1a0c0d1a080c8408011b2c27bc0c78081b27fc1f770154bc070316385460075489070d1a040f0764fc031c20031824031028031934031a1c011730027704040820527606102030f9070741fc01173c0867070d171c000000200d17180d17140d17100d170c0d17080d17040118301b88dc1f880101192c011a20549a08011928011a3854a908011934011a2454a9080d070f08f8fb0117300276240408205267061022d3f80707e4fb01173c0867070d171c0000000e0d17180d17140d17100d170c0d17080d17040118301b88bc1f880101192c011a20549a08011928011a3854a908011934011a2454a9080d070f089bfb011730027644040820526706102476f8070787fb01173c0867070d171c0d17180d17140d17100d170c67650d1708657373610d17047274206d0d07726576650408640117300610263cf807074dfb04070104096401181c0400284e01110211fc03100407040806102a1bf80f070400040804000204070104094e01040704002c054bf8040706102c46f804070106102e3ef800a58424092a241452482549928a10a10b21841042488424494a4284002184104242929224494d4a9224499244122249922421094992842424494212922421094992908424494842922424214992244992842424490a09094d2149aa1532a434492249c81012420821542a494249524992240408218410428480244992a449922449922492242549922449922449922449922449925488904a428508a9498824499284242449129290244948429224242149129290240949489284242449922449942449484292242192042925a524a924499224254992449224492192409224499224495224294412489224499224498a24854892240402411222499a2a64489514120200" + }, + "piggyBank": { + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "deposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "withdrawAmount", + "type": "uint256" + } + ], + "name": "withdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "remainingBal", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "50564d0001182e000000000000010700c13004c0004004809c0a00000000040000000a000000150000001a0000002a0000003a00000045000000570000006200000063616c6c63616c6c65726765745f73746f72616765696e70757472657475726e5f646174615f636f707972657475726e5f646174615f73697a657365616c5f72657475726e7365745f696d6d757461626c655f646174617365745f73746f7261676576616c75655f7472616e73666572726564051102a7ca0463616c6ca7d1066465706c6f7906ad4c3902a7da6700ab00b000d400ba03e50402051e05320554057a07950717081e095a0b870bb10bcc0be60b8a0d0a0e4d0ff50f78104d114d157a15a415bf15791751186018b5193a1a7a1be81b171c461c651cbc1d451e461f701fdc2145231d254e257d25ac25c325d125e5253026ca262427d127d92752790e7a1004070f0a41040a0000012f8a3908890802871f1277e03b370000010a040713000a0800000229781416070000025278040710000208870713000407100002088707130013000211e003101c0315180316140215201211e0127601040704080610029d16070800020d010004040710000352184e0311011726032c040326032804032603240403260320040326031c0403260318040326031404031607100403070607061004090610068704021100ff0310fc000315f8000316f400021500011211e0521604074004082006100831ff07074d040408080002260364000200000080260360000226035c000226035800022603540002260350000226034c000203681826034800020217e01277e003671c52710d171c0d17180d17140d17100d170c0d17080d17040d074e091101681c0182100183018914018a1c018b0c018c040187180188080cba0a0cc9090ca9090c87070c23080c87070c97070f07b5030267204e01016220016a30016824016928016b2c0eac0812c700ff000eac180cc70712ac00ff0009cc0809aa180cca0a0ca70703671c0eb708127700ff000eba180ca70712ba00ff0009aa0809bb180cba0a0ca7070367140e9708127700ff000e9a180ca707129a00ff0009aa080999180ca9090c97070367100e8708127700ff000e89180c9707128900ff000999080988180c98080c870703670c0e2708127700ff000e28180c87070d160400ff00122800ff000988080922180c82080c87070367080d26bc000d26b8000d26b4000d26b0000d26ac000d26a8000d26a4000d26a000010d269c000d2698000d2694000d2690000d268c000d2688000d2684000d2680000d16780d167c0d16700d16740d16680d166c0d16640d166000010268a0000409ff026a8000026b6004074e02016794000168980001699c000d26dc000d26d8000d26d4000d26d0000d26cc000d26c8000d26c4000d26c00001016a08036a50016a0c036a4c016a10036a48016a14036a44016a1c036a4003695c0368580367540268c0000409ff026a40040b2004074e080d26bc000d26b8000d26b4000d26b0000d26ac000d26a8000d26a4000d26a0000d269c000d2698000d2694000d2690000d268c000d2688000d2684000d2680000d16780d167c0d16700d16740d16680d166c0d16640d166000010268a0000409ff026a8000026b6004074e020d26dc000d26d8000d26d4000d26d0000d26cc000d26c8000d26c4000d26c0000d165c0d16580d16540d16500d164c0d16480d16440d16400268c0000409ff026a40040b2004074e0804074004082006100a4bfc07076701016718017350017440017058017a4c017948017c540177440eab08016204172b0b0ea8180cb808172a0b09bb0809aa180cba0a0ca80803681c0e78081728080e7a180ca80817270a09aa080977180ca7070c87070367140ec7081727070ec8180c8707172c0809880809cc180cc8080c780c0e97081727070e98180c87071729080988080999180c98080c78090e07081727070e08180c87071720080988080900180c80080c87070e48081728080e4a180ca80817240a09aa080944180ca40a0ca8080e3a08172a0a0e3b180cba0a17230b09bb080933180cb30b0cba0a0ca8080c97070c87070168140cc80801691c0c98080c87070f076d01671801775c0e7808016a0417a8080e79180c980817a7090999080977180c97070c870703671c040806100c20fb07073c0a080c000207080b04073004034e071101671c040806100e03fb07071f01681801671c087808040704094e061104070408061010e7fa0f070400040808000204070104090400124e06110211c0fd03103c020315380203163402021540021211e0040740040820061014b1fa0f070400040a1004030a031004030a021804030a001c04030a072c04030a0c2804030a062004030a04240403277827c95478092748276b54480b0c7c0854890b031a7c0a091404032708522a27225408020313701b38041f8801279354930852c3031a740c0a0a54a2080c740a0316780c6c0c0cca0a54ab080406080002260364000200000080260360000226035c000226035800022603540002260350000226034c000226034800020708920104021000030a081000030e8a0812aa00ff000e8c180cca0a128b00ff0009bb080988180cb8080ca80807485bcba58dfd010748b00de3d062010f484d7d1a2e550103127803166c0d21bc000d21b8000d21b4000d21b0000d21ac000d21a8000d21a4000d21a0000217a0004e09110112b0000113a0000119b400011abc00011bac00011ca4000117b8000118a8000cba0a0cc9090ca9090c87070c23080c87070c97070f07380501167c0160140168016b0c016904016c080287fc03177424870a08a9080284ff1c9408249409538a0902caff089a0824c80324a80a1bc701147b07087a0a1cba0724ba0b53730b0163101c8c0c0cc70753790b0237ff08b7022472071b3b0114b00b087b0c24bc0b53770b01671801661c0c03091b900114070908b9032493092407071476060896063d672739546709272727cb53c70b0c630754790b27470119741b99201f9901544709278427a753a4070ca8085487090c32070c6c0c0cc707547b090f09e709040704080610168bf80707ddfd040808000204070104094e0604001805361e061018331e011a7002a8fc24a80808890a02aaff1c9a0b249a0953b809011a7402a8ff08980b24ab02248b081bac0114c00c08c8081c080c24080853c2081cba0a0cca0a53a908011b7802b9ff0898082498081bb90114940908890a249a095388090c4b081b880114830a08a90924a9092483081487070897072d0725010407040806101aeef7070740fd040808000204070104094e061103166c0d21fc010d21f8010d21f4010d21f0010d21ec010d21e8010d21e4010d21e0010217e0014e09110112f0010113e0010119f401011afc01011bec01011ce4010117f8010118e8010cba0a0cc9090ca9090c87070c23080c87070c97070f073c0301197c01921c019318019414019a100198019c0c019704019608028bfc248b0808870b02bbff1c7b09247b075398070268ff0878092469002489081b6b0114bc0b08b8081cc80b24c80853b0081c69090cb90953970802a7ff0878082478071ba8011484080878092489085377080c4a071b77011473090898082498082473071472070887072d0743060407040806101ce7f6070739fc040808000204070104094e061103166c0d21bc010d21b8010d21b4010d21b0010d21ac010d21a8010d21a4010d21a0010217a0014e090117bc0103177c0117b8010317780117b4010317600116b0010117ac010317680117a8010317640117a0010317740117a4010317700d215c010d2158010d2154010d2150010d214c010d2148010d2144010d2140010d211c020d2118020d2114020d2110020d210c020d2108020d2104020d2100020d21f8010d21fc010d21f0010d21f4010d21e8010d21ec010d21e4010d21e0010001021840010409ff021a0002021be00104074e02110118100203185c011a1402088606031a5801176008a70724860908970c011b0c02011008021cac0824ac0753890703175001126408020201146808b40401190402011a000224020308430301147008940401187408a80803184c24a80a08a404031a681c940703177403144824940903197054790a08a2082428090893032408020312641cb30703134024b309031960522b03175454790b0318441c08080c7800530a0b08b603246308011a1c0201161802088c0224c207538807011878086808011b7c08ab0b246804084b0b011c50088c0c248c0808b808087c0924c9070887071ca70c03177824a70a24690853c80a0117581c720403127c24720801125c24230b534b080319581c690b0ccb07547a080117641f77010119601f9a0101195453970a0117681f77010119701f9901011674546907540a071c23090cb9090cc40a0ca9091f88015498070f07a90004082006101eabf40707fdf901166c0d161c0d16180d16140d16100d160c0d16080d16040d064e487b710407040408200610207ef40707d0f90d1620000000110d161c0d16180d16140d16100d160c0d16080d1604040824040706102254f40707a6f904080800020407010409244e06110407040806102439f407078bf9040808000204070104094e0611040704080610261ff4070771f9040808000204070104094e061152360d211c020d2118020d2114020d2110020d210c020d2108020d2104020d2100020d21fc010d21f8010d21f4010d21f0010d21ec010d21e8010d21e4010d21e0010d21b8000d21bc000d21b0000d21b4000d21a8000d21ac000d21a4000d21a0000001021800020409ff021ae001021ba00004074e020d215c010d2158010d2154010d2150010d214c010d2148010d2144010d2140010117580317d80101177c0317d4010316d0010117400317cc010117440317c8010117480317c40101174c0317c0010117780317dc01021840010409ff021ac001040b2004074e080d215c010d2158010d2154010d2150010d214c010d2148010d2144010d2140010d211c020d2118020d2114020d2110020d210c020d2108020d2104020d2100020d21f8010d21fc010d21f0010d21f4010d21e8010d21ec010d21e4010d21e0010001021840010409ff021a0002021be00104074e0201171c0203176001171802031764011714020317680117100203177001170c02031774011708020317780117040203177c011600020407400408200610287bf20707cdf703165c011b6c01b24c01b34401ba5401b94801bc4001b65001b8580c6c0c0c98080cc8080c3a090c29090c98080e8908129900ff000e8a180ca909098a18128800ff000988080ca8080c98080f087df701b85c0e8908129900ff000e8a180ca909128700ff000977080988180c87070c9706040820526706102afbf107074df7011a600ea708127700ff000ea9180c970712a900ff0009990809aa180ca9090c9707031760011b640eb908129900ff000eba180ca90912ba00ff0009aa0809bb180cba0a0c9a03011c680eca0812aa00ff000ecb180cba0a12cb00ff0009bb0809cc180ccb0b0cab0452620116700e6b0812bb00ff000e6c180ccb0b126c00ff0009cc080966180c6c0c0cbc000117740e7c0812cc00ff000e76180c6c0c127600ff000966080977180c67070c7c0c0119780e9708127700ff000e96180c6707129600ff000966080999180c69090c9707011a7c0ea908129900ff000ea6180c690912a600ff0009660809aa180c6a0a0ca909011b5c0eba0812aa00ff000eb6180c6a0a12b800ff0009880809b6180c68080ca80801166c08260603681c036918036714036c1003600c0364080363040117600367040820522706102cb8f007070af6052f0c0d215c010d2158010d2154010d2150010d214c010d2148010d2144010d214001010d211c020d2118020d2114020d2110020d210c020d2108020d2104020d2100020d21d8010d21dc010d21d0010d21d4010d21c8010d21cc010d21c4010d21c0010001021840010409ff021a0002021bc00104074e020117100203177001170c02031774011708020317780117040203177c0116000204074004082006102e10f0070762f5031668011b6c01b24c01b34401ba5401b94801bc4001b65001b8580c6c0c0c98080cc8080c3a090c29090c98080e8908129900ff000e8a180ca909098a18128800ff000988080ca8080c98080f0812f501b85c0e8908129900ff000e8a180ca909128700ff000977080988180c87070c970704082003176452b60610308def0707dff4011764087603011a700ea908129b00ff000ea9180c9b0b12a900ff0009990809aa180ca9090cb902011b740eb908129900ff000eba180ca90912ba00ff0009aa0809bb180cba0a0c9a04011c780eca0812aa00ff000ecb180cba0a12cb00ff0009bb0809cc180ccb0b0cba0a01167c0e6b0812bb00ff000e6c180ccb0b126c00ff0009cc080966180c6c0c0ccb0b0119680e9c0812cc00ff000e96180c6c0c129800ff000988080996180c680852360cc8080d13080d13040d0303381c033b18033a1403341003320c040820061032b8ee07070af4052f0a01187801872003176401871c03176001871803175c01871403175801871003175401870c03175001870803174c018704031748040600ff000217c0004e010112c4000117c8000118cc000119c000011bd0000e7c08176c0c0e7a180cca0a17670c09cc080977180cc7070ca70703177c0eb7081767070eba180ca707176b0a09aa0809bb180cba0a0ca7070317780e97081767070e9a180ca70717690a09aa080999180ca9090c97070317740e87081767070e89180c97071768090999080988180c98080c87070317700e27081767070e28180c87071762080988080922180c82080c87070317680d215c010d2158010d2154010d2150010d214c010d2148010d2144010d214001010d211c020d2118020d2114020d2110020d210c020d2108020d2104020d2100020d21f8010d21fc010d21f0010d21f4010d21e8010d21ec010d21e4010d21e0010001021840010409ff021a0002021be00104074e02110117080201180c0201190402011a0002011b1002011c681cc808011c701cc9090c98080119741cb909011b781cba0a0ca909011a7c1ca7070c97070c87070f07c5020119480e9708127700ff000e98180c8707129800ff000988080999180c98080c870703177c01194c0e9708127700ff000e98180c8707129800ff000988080999180c98080c87070317780119500e9708127700ff000e98180c8707129800ff000988080999180c98080c87070317740119540e9708127700ff000e98180c8707129800ff000988080999180c98080c87070317700119580e9708127700ff000e98180c8707129800ff000988080999180c98080c870703176801195c0e9708127700ff000e98180c8707129800ff000988080999180c98080c870703175c0119600e9708127700ff000e98180c8707129800ff000988080999180c98080c87070317600119640e9708127700ff000e98180c8707129800ff000988080999180c98080c87070317640d21e00100010d215c010d2158010d2154010d2150010d214c010d2148010d2144010d2140010d211c020d2118020d2114020d2110020d210c020d2108020d2104020d2100020d21f8010d21fc010d21f0010d21f4010d21e8010d21ec010d21e401021840010409ff021a0002021be00104074e021101131c02011a0c0201160802011c0402011900020117681c7a08031a50247a04011a5c24a60b031b48538b04011b601cbc02031c5424bc0b031958011c6424c90903194053290b03164c1ca6060c6808011a1402031b3c538b0401171002011218020118741c8a09031a34248a0801107024070a031a30539a0801167824620b011c7c1cc30a03134424c30c031b3853ab0c522b1c62020ca20653680c1c07060c26060ca9090c690953940c070c93000408200407061034b8ea07070af001166c0d161c0d16180d16140d16100d160c0d16080d16040d064e487b710407040408200610368bea0707ddef0d1620000000110d161c0d16180d16140d16100d160c0d16080d1604040824040706103861ea0707b3ef04080800020407010409244e06110407040806103a46ea0f07060595ef040808000204070104094e06115273011974011734149709011730147909011a7014a30324430a14a90c031c34569a011978149b0914890c24890801197c011b44149b09011b3814b90914890924ac0814890903194414ac0c031c3814430703173001175c01184c14780701193c14970803184c2497070118680119501489080119481498081478080318500117600118541478070118401487070317540d21a00100010117640116581476060d211c020d2118020d2114020d2110020d210c020d2108020d2104020d2100020d21fc010d21f8010d21f4010d21f0010d21ec010d21e8010d21e4010d21e0010d21b8010d21bc010d21b0010d21b4010d21a8010d21ac010d21a401021800020409ff021ae001021ba00104074e020d215c010d2158010d2154010d2150010d214c010d2148010d2144010d2140010117500317cc0101174c0317c8010117540317c4010316c0010117300317d0010117340317d4010117380317d8010117440317dc01021840010409ff021ac001040b2004074e080217e0004e010117f0000317580117ec000317540117e8000317500117e40003174c0116e00004074004082006103c8ce80f070605dbed0316000101174c031704010117500317080101175403170c01011758031710010117640317a0010117600317a40101175c0317a80101166c0167480118680318ac010168400119700319b001016950011a74031ab401016a58011b78031bb801016b440c98080169540ca707016a4c0c870c01675c0cb9090ca9090cc9090e9a0812aa00ff000e9b180cba0a099b18129900ff000999080cb9090ca909011a7c031abc010709060531ed0e7908129900ff000e7a180ca909127800ff000988080977180c87070c97065267040806103eb4e70f07060503ed04070408061040a5e70f070605f4ec01196c0869070d2120010d2140010802180001031844010d2148010d214c010d2150010d2154010d215801ff0218a00103185c01031760010d216401031968010217200103176c01021740014e03177c0217c0014e05110112d0010118c0010119d401011adc01011bcc01011cc4010116d8010117c8010cba0a0cc9090ca9090c67070c28080c87070c97070f079f0201177c0f0761030d211c020d2118020d2114020d2110020d210c020d2108020d2104020d2100020d21fc010d21f8010d21f4010d21f0010d21ec010d21e8010d21e4010d21e0010d21d8010d21dc010d21d0010d21d4010d21c8010d21cc010d21c4010d21c0010001021800020409ff021ae001021bc00104074e020117fc0103175c0117f8010317600117f4010317640117f0010317680117ec010317700117e8010317740117e4010317780117e00103177c04074004082006104250e60f0706059feb01176c01724c017944017a54017b48017c400176500178580c6c0c0cb8080cc8080ca9090c29090c98080e8908129900ff000e8a180ca909098a18128800ff000988080ca8080c98080708060550eb01186c01885c0e8908129900ff000e8a180ca909128700ff000977080988180c87070c9707040820031758061044cbe50f0706051aeb011a5c0ea708127700ff000ea9180c970712a900ff0009990809aa180ca9090c7902011b600eb908129900ff000eba180ca90912ba00ff0009aa0809bb180cba0a0c9a03011c640eca0812aa00ff000ecb180cba0a12cb00ff0009bb0809cc180ccb0b0cab040116680e6b0812bb00ff000e6c180ccb0b126c00ff0009cc080966180c6c0c0cbc000117700e7c0812cc00ff000e76180c6c0c127600ff000966080977180c67070c7c0c0119740e9708127700ff000e96180c6707129600ff000966080999180c69090c9707011a780ea908129900ff000ea6180c690912a600ff0009660809aa180c6a0a0ca909011b7c0eba0812aa00ff000eb6180c6a0a12b800ff0009880809b6180c68080ca80801166c011a5808a60603681c036918036714036c1003600c036408036304036204082052a70610468be40f070605dae9040920040752684e060217e0014e0505090217e0014e0511011cfc01011bf8010117f4010118f001011aec010119e801031768031c600cc707031870031b640cb8080c87071f98010ca8080319781b9901031a7456a9558956790f097d0304082004070610481de40f0706056ce901186c0d181c0d18180d18140d18100d180c0d18080d18040d084e487b7104070404082006104aeee30f0706053de901186c0d1820000000410d181c0d18180d18140d18100d180c0d18080d1804040824040706104cbfe30f0706050ee904080800020407010409244e061104074004082006104ea0e30f070605efe801176c017250017340017458017b48017c54017a4c0178440ea608126600ff000ea9180c690912a600ff0009660809aa180c6a0a0ca90903197c0e8908129900ff000e8a180ca909128a00ff0009aa080988180ca8080c98000ec808128800ff000ec9180c980812c900ff0009990809cc180cc9090c890c0eb808128800ff000eb9180c980812b900ff0009990809bb180cb9090c890a0e4808128800ff000e49180c9808124900ff000999080944180c94090c890b0e3808128800ff000e39180c9808123900ff000999080933180c93090c89060e2808128800ff000e29180c9808122900ff000999080922180c92090c98080318700316640c6808031b74031a600cab090c9808031068031c780c0c09011a7c0ca9090c980807080605cee701186c01885c0e8908129900ff000e8a180ca909128700ff000977080988180c87070c970704082003175c06105049e20f07060598e701176c01195c0897080d181c0d18180d18140d18100d180c0d18080d18040318480d0808c379a0029804249807011a74087a0924a90653770601177808670a247a0201177008270b247b0c53220c53660c01177c087c0c247c02011760082704247406532206011768086703247307011264087202031302178000031204061052a507011a8400031a6c0119800001108800011b8c000118741c8a07248a0203194c01185c248908031858537802011870031b541c8b07248b0b01197824900803185053780b011690001c90080c87070118940053720b01177c14760424760601196014980a1c9807249809537609146a080116980024b40714780a031a7c568701139c00011a6814a60814980c24980824a609011a6414a306149606148606247c0814860614b408147c0a011778147007011970011b54149b09011b5014b90924270b14b909142707011b74011c6c14bc0b011c5814cb0b0c87070ca70701187c0cb8080c69090c87070c97070707060524e601175c01184c1478065268061054bfe00f0706050ee604070101184852694e06110117e4010317580117e00103175c04074004082006105695e00f070605e4e501175c027a1f247a0701185808780024800953770901177808790912990103195412aae0031a5001146c014b58014c5c0148500146540e8908129900ff000e8a180ca909128a00ff0009aa080988180ca8080c98030e6808128800ff000e69180c9808126900ff000999080966180c69090c89060ec808128800ff000ec9180c980812c900ff0009990809cc180cc9090c89020eb808128800ff000eb9180c980812b900ff0009990809bb180cb9090c9808011950029c3f249c0908900a240a0b53990b011954089b0b12cce0088a0a082c0c031214031c20242c0c08ca0a1c8a09031824031a1c248a00539c00086b0b080b0c031c5424bc08246b09083909089808246c091c380b03132c24380253b9020149400316281c6c0c0ccb0b53b0020e9a0812aa00ff000e9b180cba0a129b00ff0009bb08014c440999180cb9090ca9000ec908129900ff000eca180ca90903195001464812cb00ff0009bb0809cc180ccb0b0e6c0812cc00ff000e6a180cca0a126c00ff0009cc0801494c0966180c6c0c0cac060e9a0812aa00ff000e9c180cca0a129700ff000977080999180c97070ca70708270303174824730408460703164c246709011a500cba0a03193053440908a909031a4424a90603105008600c279b27c053cb00273b277a537b0a0cc90b54b00a0313400319380c930b03173c031c340c7c0c0ccb07011954279c278b538c0b0318180c890c55cb547a0b0f0bbd03011a4c01183c1ca809011730549704011b500117341cb70a24b70c54ac06011b44011c381cbc0c0cac0b53b4060117480118401c87070cc7070c9a0a0ca7075476020f02770304074004082006105829de0f07060578e30116340e6708127700ff000e69180c9707126900ff000999080966180c69090c7902011b380eb908129900ff000eba180ca90912ba00ff0009aa0809bb180cba0a0c9a03011c3c0eca0812aa00ff000ecb180cba0a12cb00ff0009bb0809cc180ccb0b0cab040116400e6b0812bb00ff000e6c180ccb0b126c00ff0009cc080966180c6c0c0cbc000117180e7c0812cc00ff000e76180c6c0c127600ff000966080977180c67070c7c0c0119540e9708127700ff000e96180c6707129600ff000966080999180c69090c9707011a1c0ea908129900ff000ea6180c690912a600ff0009660809aa180c6a0a0ca909011b200eba0812aa00ff000eb6180c6a0a12b800ff0009880809b6180c68080ca808011a6c03a85c03a95803a75403ac5003a04c03a44803a34401172401184c0c870701182c0119500c98080c87070118280119440c98080119480c98080c870703a2400707060520e204082001171406105ac0dc0f0706050fe2011a600ea708127700ff000ea9180c970712a900ff0009990809aa180ca9090c7902011b640eb908129900ff000eba180ca90912ba00ff0009aa0809bb180cba0a0c9a03011c680eca0812aa00ff000ecb180cba0a12cb00ff0009bb0809cc180ccb0b0cab040116700e6b0812bb00ff000e6c180ccb0b126c00ff0009cc080966180c6c0c0cbc000117740e7c0812cc00ff000e76180c6c0c127600ff000966080977180c67070c7c0c0119780e9708127700ff000e96180c6707129600ff000966080999180c69090c9707011a580ea908129900ff000ea6180c690912a600ff0009660809aa180c6a0a0ca909011b5c0eba0812aa00ff000eb6180c6a0a12b800ff0009880809b6180c68080ca808011a6c011614086a0a03a81c03a91803a71403ac1003a00c03a40803a30403a2021700024e051101192427971b68e01f8801549708011b2827b7011a2c27a953a7090cab075378090112482727011c4c27c853c7080116442767011b5027ba53b70a0cb60753780a0c62070cbc080c870753790a070a060585e0011710020118140201191c02011a0c02011b0402011c1802011608020ca9090cb8080c98080c6c0c0cc7070c87070707060551e001160002011714027720031778526806105ce8da0f07060537e001176c011878088707031680010218800104094e0411011780012967b9f30516e0040820040706105eb7da0f07060506e001186c0d181c0d18180d18140d18100d180c0d18080d18040d084e487b7104070404082006106088da0f070605d7df01186c0d1820000000410d181c0d18180d18140d18100d180c0d18080d1804040824040706106259da0f070605a8df04080800020407010409240400644e06110211fc03100407040806106634da0f070400040808000204070104090400684e06110211bc03104003153c031638011648011544031b1c03162c0cb6060319340314280c490b0c6b09031c20031a180cca0a0315240c5a0a0ca9090f09ab0152850317040820525706106ad5d90707990104070800020317140857070d171c000000200d17180d17140d17100d170c0d17080d1704011934279a0315301b58e01f8801031a10549a08011318273901141c27405349000112202729011b2827b553b905011c2427c9011a2c27a653a9060cac095395060cc2090cba0a0ca9090c430a03100c031a0454a0080319085496080d070f081301011730027520040820525706106c3bd90707ff000117140875050d151c0000000f0d15180d15140d15100d150c0d15080d15040117301b77c01f770101183401191054890701180c0119045498070118085486070d050f07b900011630026540040820525706106ee1d80707a5000117140875050d151c0d15180d15140d15100d150c6c65640d1508206661690d1504736665720d055472616e02626024620801173408870924790a53880a01171808a70824780b01171c08b70c247c0653bb0653aa0601172008760624760a01172808a70b247b0553aa0501172408750524750a01172c087a0a01170372037904037808037c0c037610037b14037518037a1c01104001153c01163802114413000004070610707ed804070106107276d800a58424092a241452482549928a10a116420821849008111191921021400821849090a424495293922449922491922409494892242421499290842449421292240949109224111111112222222292244988442a22222222222449922449224945444444444444442449921089544444444492244924a924449224499224499224499224499224499224499224499224499224499224499224499224492121a1292449b542869446444492902184104208954a925025492949922404082184104284909084240908084822222222a2111111114992249292244992244992244992244992244992542a4949524992242a444825214992244992244992244992244992448508a98988888888464444442449924892942449922449922449922449922449a24284d444444444449148242291482422222222222222222222228248448d44922411499224114992244992244992242949922422499224499224499224499224499224499224492444922449908408244992142224ad1021b54284d42222222222222222222222228844544444444422118944229188442a22222222222222222222228248444522914824128924449224499224494812924412929024294412929024494212922409494892929084244942129224094948922424214992908424499224494a211211111121222222222222228248444522914824219224499224494292902492908424490a912421094992842424491292902449484292242109494a5292242192244992244992104544449224499224499224499224499224499224491211111121222222222222228248448d88882449922449220949489224210949922424214992842424499290842449129290244942129224494842922488888888888888888888888848448d8888244992244992248924224992244992a42449924821922449822444204992a41021698524a4962449929424499224499224499224499224099244444444444444444444444424a222222222128944241289442452512412894412924824128944229124924822892449922421494892481292902415920a491221222222444444444c3422222222499244222222222222222222222222824844452291482412892421499224499224214948922409494892242449484292242109499284242449129290244948429224210949928424244912929024499224492924a9a2a21111114992244952450a499224499084248124499242129226214992244948429224210949929084244948429224242149129290240949489224499224499224242149929024499224099224499224499224499222211211499224499224914492244912498a2449922449922449922449922449924292d448240949922449922449929084244948429224242149129290244992244992244992244992244992842424491292242449484292242109499224499224492a95244992a49294489224499224499224929024210949928424244912929024494842922421094992842424491292902449484292244992244992244992242149421292240949489224242149929084244942129224094948922424214992908424499224498aa62429254929292549922422222292244922492149125123924292244912242149204992a49084244d1532a43449922449922449540a119240922429499252524a4a4992244952242944124892244992244991a410499204814090244992244992244992549224499216120200" } } \ No newline at end of file diff --git a/substrate/frame/revive/rpc/examples/js/src/build-contracts.ts b/substrate/frame/revive/rpc/examples/js/src/build-contracts.ts index 3e9d036d1b7d..620c5a046d54 100644 --- a/substrate/frame/revive/rpc/examples/js/src/build-contracts.ts +++ b/substrate/frame/revive/rpc/examples/js/src/build-contracts.ts @@ -30,6 +30,7 @@ let evmContracts: Map = new Map() const input = [ { file: 'Event.sol', contract: 'EventExample', keypath: 'event' }, { file: 'Revert.sol', contract: 'RevertExample', keypath: 'revert' }, + { file: 'PiggyBank.sol', contract: 'PiggyBank', keypath: 'piggyBank' }, ] for (const { keypath, contract, file } of input) { diff --git a/substrate/frame/revive/rpc/examples/js/src/piggy-bank.ts b/substrate/frame/revive/rpc/examples/js/src/piggy-bank.ts new file mode 100644 index 000000000000..418e1e41035b --- /dev/null +++ b/substrate/frame/revive/rpc/examples/js/src/piggy-bank.ts @@ -0,0 +1,17 @@ +//! Run with bun run script-event.ts +import { parseEther } from 'ethers' +import { call, getContract, deploy } from './lib.ts' + +try { + const { abi, bytecode } = getContract('piggyBank') + const address = await deploy(bytecode, abi) + + let receipt = await call('deposit', address, abi, [], { value: parseEther('3.0') }) + console.log('Deposit Receipt:', receipt?.toJSON()) + + receipt = await call('withdraw', address, abi, [parseEther('1.0')]) + console.log('Withdraw Receipt:', receipt?.toJSON()) +} catch (err) { + console.error(err) +} + diff --git a/substrate/frame/revive/src/lib.rs b/substrate/frame/revive/src/lib.rs index 5ca0042d929b..e931976ec4f4 100644 --- a/substrate/frame/revive/src/lib.rs +++ b/substrate/frame/revive/src/lib.rs @@ -47,7 +47,7 @@ use crate::{ storage::{meter::Meter as StorageMeter, ContractInfo, DeletionQueueManager}, wasm::{CodeInfo, RuntimeCosts, WasmBlob}, }; -use alloc::boxed::Box; +use alloc::{boxed::Box, string::String}; use codec::{Codec, Decode, Encode}; use environmental::*; use frame_support::{ @@ -1265,6 +1265,13 @@ where debug, collect_events, ); + + log::debug!(target: LOG_TARGET, "Result: {}, Revert: {}, Debug message: {:?}", + result.result.is_ok(), + result.result.as_ref().map_or(false, |v| v.did_revert()), + String::from_utf8(result.debug_message) + ); + let result = EthContractResult { gas_required: result.gas_required, storage_deposit: result.storage_deposit.charge_or_zero(), @@ -1310,6 +1317,12 @@ where collect_events, ); + log::debug!(target: LOG_TARGET, "Result: {}, Revert: {}, Debug message: {:?}", + result.result.is_ok(), + result.result.as_ref().map_or(false, |v| v.result.did_revert()), + String::from_utf8(result.debug_message) + ); + let result = EthContractResult { gas_required: result.gas_required, storage_deposit: result.storage_deposit.charge_or_zero(), From cadb56c5a9b78d5f3d18ba91fea6c841d42aecdc Mon Sep 17 00:00:00 2001 From: pgherveou Date: Wed, 13 Nov 2024 16:44:04 +0100 Subject: [PATCH 02/14] wip --- .../revive/rpc/examples/js/abi/event.json | 34 +++++ .../revive/rpc/examples/js/abi/piggyBank.json | 65 +++++++++ .../revive/rpc/examples/js/abi/revert.json | 14 ++ .../frame/revive/rpc/examples/js/bun.lockb | Bin 23039 -> 45391 bytes .../rpc/examples/js/contracts/PiggyBank.sol | 1 - .../revive/rpc/examples/js/evm-contracts.json | 111 --------------- .../frame/revive/rpc/examples/js/package.json | 9 +- .../revive/rpc/examples/js/pvm-contracts.json | 111 --------------- .../revive/rpc/examples/js/pvm/event.polkavm | Bin 0 -> 5186 bytes .../rpc/examples/js/pvm/piggyBank.polkavm | Bin 0 -> 12334 bytes .../revive/rpc/examples/js/pvm/revert.polkavm | Bin 0 -> 2490 bytes .../rpc/examples/js/src/build-contracts.ts | 13 +- .../frame/revive/rpc/examples/js/src/event.ts | 4 +- .../frame/revive/rpc/examples/js/src/lib.ts | 26 ++-- .../revive/rpc/examples/js/src/piggy-bank.ts | 24 ++-- .../revive/rpc/examples/js/src/revert.ts | 4 +- .../revive/rpc/examples/js/src/transfer.ts | 17 +++ .../js/types/ethers-contracts/Event.ts | 133 ++++++++++++++++++ .../js/types/ethers-contracts/PiggyBank.ts | 122 ++++++++++++++++ .../js/types/ethers-contracts/Revert.ts | 84 +++++++++++ .../js/types/ethers-contracts/common.ts | 131 +++++++++++++++++ .../factories/Event__factory.ts | 51 +++++++ .../factories/PiggyBank__factory.ts | 82 +++++++++++ .../factories/Revert__factory.ts | 31 ++++ .../types/ethers-contracts/factories/index.ts | 6 + .../js/types/ethers-contracts/index.ts | 10 ++ .../frame/revive/rpc/examples/package.json | 1 - 27 files changed, 826 insertions(+), 258 deletions(-) create mode 100644 substrate/frame/revive/rpc/examples/js/abi/event.json create mode 100644 substrate/frame/revive/rpc/examples/js/abi/piggyBank.json create mode 100644 substrate/frame/revive/rpc/examples/js/abi/revert.json delete mode 100644 substrate/frame/revive/rpc/examples/js/evm-contracts.json delete mode 100644 substrate/frame/revive/rpc/examples/js/pvm-contracts.json create mode 100644 substrate/frame/revive/rpc/examples/js/pvm/event.polkavm create mode 100644 substrate/frame/revive/rpc/examples/js/pvm/piggyBank.polkavm create mode 100644 substrate/frame/revive/rpc/examples/js/pvm/revert.polkavm create mode 100644 substrate/frame/revive/rpc/examples/js/src/transfer.ts create mode 100644 substrate/frame/revive/rpc/examples/js/types/ethers-contracts/Event.ts create mode 100644 substrate/frame/revive/rpc/examples/js/types/ethers-contracts/PiggyBank.ts create mode 100644 substrate/frame/revive/rpc/examples/js/types/ethers-contracts/Revert.ts create mode 100644 substrate/frame/revive/rpc/examples/js/types/ethers-contracts/common.ts create mode 100644 substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/Event__factory.ts create mode 100644 substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/PiggyBank__factory.ts create mode 100644 substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/Revert__factory.ts create mode 100644 substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/index.ts create mode 100644 substrate/frame/revive/rpc/examples/js/types/ethers-contracts/index.ts delete mode 100644 substrate/frame/revive/rpc/examples/package.json diff --git a/substrate/frame/revive/rpc/examples/js/abi/event.json b/substrate/frame/revive/rpc/examples/js/abi/event.json new file mode 100644 index 000000000000..a64c920c4068 --- /dev/null +++ b/substrate/frame/revive/rpc/examples/js/abi/event.json @@ -0,0 +1,34 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "string", + "name": "message", + "type": "string" + } + ], + "name": "ExampleEvent", + "type": "event" + }, + { + "inputs": [], + "name": "triggerEvent", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/substrate/frame/revive/rpc/examples/js/abi/piggyBank.json b/substrate/frame/revive/rpc/examples/js/abi/piggyBank.json new file mode 100644 index 000000000000..e6655889e21a --- /dev/null +++ b/substrate/frame/revive/rpc/examples/js/abi/piggyBank.json @@ -0,0 +1,65 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "deposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "getDeposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "withdrawAmount", + "type": "uint256" + } + ], + "name": "withdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "remainingBal", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/substrate/frame/revive/rpc/examples/js/abi/revert.json b/substrate/frame/revive/rpc/examples/js/abi/revert.json new file mode 100644 index 000000000000..4a7f2342421a --- /dev/null +++ b/substrate/frame/revive/rpc/examples/js/abi/revert.json @@ -0,0 +1,14 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "doRevert", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/substrate/frame/revive/rpc/examples/js/bun.lockb b/substrate/frame/revive/rpc/examples/js/bun.lockb index 8bf47d7eb8b82734467165627413c33adede6fd6..700dca51da2ad3f843e890258b59c16fd4df6457 100755 GIT binary patch literal 45391 zcmeIb30#a__%}XfS}g4;ODXM^_C+OWFCipLX))DQlh&DOBbf+M_7;&PYa1d}%zvnvF+3u}5ila5d7<5ffT976+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ples/js/pvm/piggyBank.polkavm b/substrate/frame/revive/rpc/examples/js/pvm/piggyBank.polkavm new file mode 100644 index 0000000000000000000000000000000000000000..1a45c15d53f68431b7e5c1dff297c768e1160e97 GIT binary patch literal 12334 zcmd5?eQ+G*dEa;6)$Y4@yQkH8wYzt>!8)<{B;zIyby5LND$GGnMtD@+K{TlnWFw=K zEQlh@(n%IGE^&}#I~^lCST=6zfNV=xZJc1hUzu@$scq~(NQX&DhcZfm0KsYaYU3eJ z-QT-+@>d<7GYOsE+_N9=`|SJqyubJNJi85d-zkt!&lmh3QG_4QmyQUv(wgl7o+3f` zML8r2nG3lIavS8!kY$j2mv(k?S>D~Yyyu>kJzwu$+P1v?fv#0O-OGDcbw6-V>(ZX3 z_uTvSuKo+}SGErEuqib$M6k*Zbw~FZ+Tx`HyYF9$~NWvT%^TDTyW5l-y8~DOs$1 zO_^ZNv%~63>Q@7Ofky&+0&i)i{zd&qWxp&l!$-r5XU#SbmVeRuroG9&Gjd&YL3AV* za+iGS@TcDWRP>q~uh}>|QW1?O<9n}-T=)K*%EVtK)+Dwhb|wxaq^j>$ovzwh{SVcR z{hL8Mt{4owN7XiuZtw9Re&hHksM?dZ0t z+lFpyy3KT3(v>A@8OgfjA%lFAjF@DdOV(>-gG7cLGR(At0qwY|O{&_EqFu}Qaf?!_ zJWa*6iY0_Bs~{coN!BCnRb<7y&=dftX8a-p>fjiD9 zN*f_<4q4eidTL2m6B(!{{V6h-A$`fv9!8c)_VvNggrn_e_S~R)$Tu#S&IF@bHCr=bt;;Q$cR!6AV_1 z$4S;i?WEn!n{BCbKks;7GkQTfBpZeF^ETMKRc_tri2oGU5C_M$p);a>2Jxmg>9{hadQ`mk{qCn;XND;E-)V{C>XE5^tsgc z_19mzjwq?WKC$!L4~eCz;Zs|mUnNp=kcM0I_!*+dPeVR}yazc2c^mQuWSRhK2?x{g zdxSXCghW0fBzlIB*eOEXHwdv#6Jozj&O>UOqE(%P)I$`#CEYGr>5v|i3>YLw1~t+v z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fb8 zvep`Sm}~GJZixhhUqhw2={kIgSCOdZv;B1XKnZcZ#Bo0ByV8@g zHl?P&BWus8fLcCVx8l$UM}I0Slv)kRAr_ zaM*5qECN>JvS-1q8j++?afS$mNVI(BgrzO%S-G&Aar1j-ug zQoIw7^NvAj)Whgps6AoCcV3)=L5eTx_!gTiuN=R7c;hzSn5ytd(t}*^Ge#yJ!3b93 zVJ`VU3Qt~Gdf|FxEi~0p<8N@kXze&}%gisyhnoKl4Dd`b=gO-KLod!dfZs!@p)7sQbxA-|(=^M}^!zd(` ztSrAE?-p;_ZAiqB@|N>|oSP#rYSH=LptkW#OcYAI!+4@`IFnk`!7uX#%p5D~E|{d5 zCZKx134Wz<-Ye8yS2^O1^3H`(2l zKJ0vK_!Q@B%`aGfjfpEHR);I|h1P}Zc+w-|ymJ@)u>`-3)mKQnwD5~mefx=H%4eG5 zmowhTPjl6B}VbOo#UH%;%%dgJig-aH|qizZi7kwou9^W JpgkTJ{s(-6RoDOk literal 0 HcmV?d00001 diff --git a/substrate/frame/revive/rpc/examples/js/pvm/revert.polkavm b/substrate/frame/revive/rpc/examples/js/pvm/revert.polkavm new file mode 100644 index 0000000000000000000000000000000000000000..7505c402f21b7f8a16914f1f067f94eebb9b3c96 GIT binary patch literal 2490 zcmbtVZ)_V$72h{A-I-nQI_r&NZ|v2@343u80z@Ucrn-P!%c6FYMv=2Z5h`i}ah+b% zQfxO#{|H5pyV&VTRK7#a9Uy_!JDTv};6Ua2=fj~Bkm?XfAU+`7ha&L_z9At6HEnof zn}!3OiiG8TJ3GHOzj-tBdvB&be@uZpn$q|ISAIUk-c?d8!(_(+d@Ou=@Hu_%{Dn%n zFuQP~RH$4iohuhACr+O|d!aJ>rG>(Yx!KC>;_SkO!ih?0_FVZ?p;Ri&9SD&sVPBqI zSg301T;cq}S1zixqft_|i^`Vrmhv0rG~6V=Ab%o%C++ly?3e7f?62%I>L1jD{G0qf z|A7C6Ya%4_7lW59#@qBGOji{6)cRpj6J)K+UV8B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*-qE%Uhdc!ntI0W$<@7XEmvRl zyj = new Map() -let evmContracts: Map = new Map() const input = [ { file: 'Event.sol', contract: 'EventExample', keypath: 'event' }, { file: 'Revert.sol', contract: 'RevertExample', keypath: 'revert' }, @@ -42,16 +40,17 @@ for (const { keypath, contract, file } of input) { console.log(`Compile with solc ${file}`) const out = JSON.parse(evmCompile(input)) const entry = out.contracts[file][contract] - evmContracts.set(keypath, { abi: entry.abi, bytecode: entry.evm.bytecode.object }) + writeFileSync(join('evm', `${keypath}.bin`), Buffer.from(entry.evm.bytecode.object, 'hex')) + writeFileSync(join('abi', `${keypath}.json`), JSON.stringify(entry.abi, null, 2)) } { console.log(`Compile with revive ${file}`) const out = await compile(input) const entry = out.contracts[file][contract] - pvmContracts.set(keypath, { abi: entry.abi, bytecode: entry.evm.bytecode.object }) + writeFileSync( + join('pvm', `${keypath}.polkavm`), + Buffer.from(entry.evm.bytecode.object, 'hex') + ) } } - -writeFileSync('pvm-contracts.json', JSON.stringify(Object.fromEntries(pvmContracts), null, 2)) -writeFileSync('evm-contracts.json', JSON.stringify(Object.fromEntries(evmContracts), null, 2)) diff --git a/substrate/frame/revive/rpc/examples/js/src/event.ts b/substrate/frame/revive/rpc/examples/js/src/event.ts index 95e630a43461..94cc2560272e 100644 --- a/substrate/frame/revive/rpc/examples/js/src/event.ts +++ b/substrate/frame/revive/rpc/examples/js/src/event.ts @@ -3,8 +3,8 @@ import { call, getContract, deploy } from './lib.ts' try { const { abi, bytecode } = getContract('event') - const address = await deploy(bytecode, abi) - const receipt = await call('triggerEvent', address, abi) + const contract = await deploy(bytecode, abi) + const receipt = await call('triggerEvent', await contract.getAddress(), abi) if (receipt) { for (const log of receipt.logs) { console.log('Event log:', JSON.stringify(log, null, 2)) diff --git a/substrate/frame/revive/rpc/examples/js/src/lib.ts b/substrate/frame/revive/rpc/examples/js/src/lib.ts index 7f6fc19aea75..9ac0491dd2b7 100644 --- a/substrate/frame/revive/rpc/examples/js/src/lib.ts +++ b/substrate/frame/revive/rpc/examples/js/src/lib.ts @@ -10,6 +10,7 @@ import { readFileSync } from 'node:fs' import type { compile } from '@parity/revive' import { spawn } from 'node:child_process' import { parseArgs } from 'node:util' +import { BaseContract } from 'ethers' type CompileOutput = Awaited> type Abi = CompileOutput['contracts'][string][string]['abi'] @@ -41,7 +42,7 @@ if (geth) { '--http.api', 'web3,eth,debug,personal,net', '--http.port', - '8545', + '8546', '--dev', '--verbosity', '0', @@ -54,11 +55,15 @@ if (geth) { await new Promise((resolve) => setTimeout(resolve, 500)) } -const provider = new JsonRpcProvider( - westend ? 'https://westend-asset-hub-eth-rpc.polkadot.io' : 'http://localhost:8545' +export const provider = new JsonRpcProvider( + westend + ? 'https://westend-asset-hub-eth-rpc.polkadot.io' + : geth + ? 'http://localhost:8546' + : 'http://localhost:8545' ) -const signer = privateKey ? new Wallet(privateKey, provider) : await provider.getSigner() +export const signer = privateKey ? new Wallet(privateKey, provider) : await provider.getSigner() console.log(`Signer address: ${await signer.getAddress()}, Nonce: ${await signer.getNonce()}`) /** @@ -66,18 +71,16 @@ console.log(`Signer address: ${await signer.getAddress()}, Nonce: ${await signer * @param name - the contract name */ export function getContract(name: string): { abi: Abi; bytecode: string } { - const file = geth - ? readFileSync('evm-contracts.json', 'utf8') - : readFileSync('pvm-contracts.json', 'utf8') - const contracts = JSON.parse(file) as Record - return contracts[name] + const bytecode = geth ? readFileSync(`evm/${name}.bin`) : readFileSync(`pvm/${name}.polkavm`) + const abi = JSON.parse(readFileSync(`abi/${name}.json`, 'utf8')) as Abi + return { abi, bytecode: Buffer.from(bytecode).toString('hex') } } /** * Deploy a contract * @returns the contract address **/ -export async function deploy(bytecode: string, abi: Abi, args: any[] = []): Promise { +export async function deploy(bytecode: string, abi: Abi, args: any[] = []): Promise { console.log('Deploying contract with', args) const contractFactory = new ContractFactory(abi, bytecode, signer) @@ -85,7 +88,8 @@ export async function deploy(bytecode: string, abi: Abi, args: any[] = []): Prom await contract.waitForDeployment() const address = await contract.getAddress() console.log(`Contract deployed: ${address}`) - return address + + return contract } /** diff --git a/substrate/frame/revive/rpc/examples/js/src/piggy-bank.ts b/substrate/frame/revive/rpc/examples/js/src/piggy-bank.ts index 418e1e41035b..aaaac2dc9e18 100644 --- a/substrate/frame/revive/rpc/examples/js/src/piggy-bank.ts +++ b/substrate/frame/revive/rpc/examples/js/src/piggy-bank.ts @@ -1,17 +1,23 @@ -//! Run with bun run script-event.ts -import { parseEther } from 'ethers' -import { call, getContract, deploy } from './lib.ts' +import { provider, call, getContract, deploy } from './lib.ts' +import { PiggyBank } from '../types/ethers-contracts/PiggyBank' try { const { abi, bytecode } = getContract('piggyBank') - const address = await deploy(bytecode, abi) + const contract = (await deploy(bytecode, abi)) as PiggyBank + const address = await contract.getAddress() - let receipt = await call('deposit', address, abi, [], { value: parseEther('3.0') }) - console.log('Deposit Receipt:', receipt?.toJSON()) + let receipt = await call('deposit', address, abi, [], { + value: 10_000_000_000n, + }) + console.log('Deposit receipt:', receipt?.status) + console.log(`Contract balance: ${await provider.getBalance(address)}`) - receipt = await call('withdraw', address, abi, [parseEther('1.0')]) - console.log('Withdraw Receipt:', receipt?.toJSON()) + console.log('deposit: ', await contract.getDeposit()) + + receipt = await call('withdraw', address, abi, [2_000_000_000n]) + console.log('Withdraw receipt:', receipt?.status) + console.log(`Contract balance: ${await provider.getBalance(address)}`) + console.log('deposit: ', await contract.getDeposit()) } catch (err) { console.error(err) } - diff --git a/substrate/frame/revive/rpc/examples/js/src/revert.ts b/substrate/frame/revive/rpc/examples/js/src/revert.ts index 5fb3ccde6fae..ea1bf4eceeb9 100644 --- a/substrate/frame/revive/rpc/examples/js/src/revert.ts +++ b/substrate/frame/revive/rpc/examples/js/src/revert.ts @@ -3,8 +3,8 @@ import { call, getContract, deploy } from './lib.ts' try { const { abi, bytecode } = getContract('revert') - const address = await deploy(bytecode, abi) - await call('doRevert', address, abi) + const contract = await deploy(bytecode, abi) + await call('doRevert', await contract.getAddress(), abi) } catch (err) { console.error(err) } diff --git a/substrate/frame/revive/rpc/examples/js/src/transfer.ts b/substrate/frame/revive/rpc/examples/js/src/transfer.ts new file mode 100644 index 000000000000..ae2dd50f2af8 --- /dev/null +++ b/substrate/frame/revive/rpc/examples/js/src/transfer.ts @@ -0,0 +1,17 @@ +import { parseEther } from 'ethers' +import { provider, signer } from './lib.ts' + +const recipient = '0x75E480dB528101a381Ce68544611C169Ad7EB342' +try { + console.log(`Signer balance: ${await provider.getBalance(signer.address)}`) + console.log(`Recipient balance: ${await provider.getBalance(recipient)}`) + await signer.sendTransaction({ + to: recipient, + value: parseEther('1.0'), + }) + console.log(`Sent: ${parseEther('1.0')}`) + console.log(`Signer balance: ${await provider.getBalance(signer.address)}`) + console.log(`Recipient balance: ${await provider.getBalance(recipient)}`) +} catch (err) { + console.error(err) +} diff --git a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/Event.ts b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/Event.ts new file mode 100644 index 000000000000..50e4d8344c92 --- /dev/null +++ b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/Event.ts @@ -0,0 +1,133 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumberish, + BytesLike, + FunctionFragment, + Result, + Interface, + EventFragment, + AddressLike, + ContractRunner, + ContractMethod, + Listener, +} from "ethers"; +import type { + TypedContractEvent, + TypedDeferredTopicFilter, + TypedEventLog, + TypedLogDescription, + TypedListener, + TypedContractMethod, +} from "./common"; + +export interface EventInterface extends Interface { + getFunction(nameOrSignature: "triggerEvent"): FunctionFragment; + + getEvent(nameOrSignatureOrTopic: "ExampleEvent"): EventFragment; + + encodeFunctionData( + functionFragment: "triggerEvent", + values?: undefined + ): string; + + decodeFunctionResult( + functionFragment: "triggerEvent", + data: BytesLike + ): Result; +} + +export namespace ExampleEventEvent { + export type InputTuple = [ + sender: AddressLike, + value: BigNumberish, + message: string + ]; + export type OutputTuple = [sender: string, value: bigint, message: string]; + export interface OutputObject { + sender: string; + value: bigint; + message: string; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export interface Event extends BaseContract { + connect(runner?: ContractRunner | null): Event; + waitForDeployment(): Promise; + + interface: EventInterface; + + queryFilter( + event: TCEvent, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + queryFilter( + filter: TypedDeferredTopicFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + + on( + event: TCEvent, + listener: TypedListener + ): Promise; + on( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + once( + event: TCEvent, + listener: TypedListener + ): Promise; + once( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + listeners( + event: TCEvent + ): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners( + event?: TCEvent + ): Promise; + + triggerEvent: TypedContractMethod<[], [void], "nonpayable">; + + getFunction( + key: string | FunctionFragment + ): T; + + getFunction( + nameOrSignature: "triggerEvent" + ): TypedContractMethod<[], [void], "nonpayable">; + + getEvent( + key: "ExampleEvent" + ): TypedContractEvent< + ExampleEventEvent.InputTuple, + ExampleEventEvent.OutputTuple, + ExampleEventEvent.OutputObject + >; + + filters: { + "ExampleEvent(address,uint256,string)": TypedContractEvent< + ExampleEventEvent.InputTuple, + ExampleEventEvent.OutputTuple, + ExampleEventEvent.OutputObject + >; + ExampleEvent: TypedContractEvent< + ExampleEventEvent.InputTuple, + ExampleEventEvent.OutputTuple, + ExampleEventEvent.OutputObject + >; + }; +} diff --git a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/PiggyBank.ts b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/PiggyBank.ts new file mode 100644 index 000000000000..9ba06338c0fc --- /dev/null +++ b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/PiggyBank.ts @@ -0,0 +1,122 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumberish, + BytesLike, + FunctionFragment, + Result, + Interface, + ContractRunner, + ContractMethod, + Listener, +} from "ethers"; +import type { + TypedContractEvent, + TypedDeferredTopicFilter, + TypedEventLog, + TypedListener, + TypedContractMethod, +} from "./common"; + +export interface PiggyBankInterface extends Interface { + getFunction( + nameOrSignature: "deposit" | "getDeposit" | "owner" | "withdraw" + ): FunctionFragment; + + encodeFunctionData(functionFragment: "deposit", values?: undefined): string; + encodeFunctionData( + functionFragment: "getDeposit", + values?: undefined + ): string; + encodeFunctionData(functionFragment: "owner", values?: undefined): string; + encodeFunctionData( + functionFragment: "withdraw", + values: [BigNumberish] + ): string; + + decodeFunctionResult(functionFragment: "deposit", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "getDeposit", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "owner", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "withdraw", data: BytesLike): Result; +} + +export interface PiggyBank extends BaseContract { + connect(runner?: ContractRunner | null): PiggyBank; + waitForDeployment(): Promise; + + interface: PiggyBankInterface; + + queryFilter( + event: TCEvent, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + queryFilter( + filter: TypedDeferredTopicFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + + on( + event: TCEvent, + listener: TypedListener + ): Promise; + on( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + once( + event: TCEvent, + listener: TypedListener + ): Promise; + once( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + listeners( + event: TCEvent + ): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners( + event?: TCEvent + ): Promise; + + deposit: TypedContractMethod<[], [bigint], "payable">; + + getDeposit: TypedContractMethod<[], [bigint], "view">; + + owner: TypedContractMethod<[], [string], "view">; + + withdraw: TypedContractMethod< + [withdrawAmount: BigNumberish], + [bigint], + "nonpayable" + >; + + getFunction( + key: string | FunctionFragment + ): T; + + getFunction( + nameOrSignature: "deposit" + ): TypedContractMethod<[], [bigint], "payable">; + getFunction( + nameOrSignature: "getDeposit" + ): TypedContractMethod<[], [bigint], "view">; + getFunction( + nameOrSignature: "owner" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "withdraw" + ): TypedContractMethod< + [withdrawAmount: BigNumberish], + [bigint], + "nonpayable" + >; + + filters: {}; +} diff --git a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/Revert.ts b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/Revert.ts new file mode 100644 index 000000000000..4478811fb537 --- /dev/null +++ b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/Revert.ts @@ -0,0 +1,84 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BytesLike, + FunctionFragment, + Result, + Interface, + ContractRunner, + ContractMethod, + Listener, +} from "ethers"; +import type { + TypedContractEvent, + TypedDeferredTopicFilter, + TypedEventLog, + TypedListener, + TypedContractMethod, +} from "./common"; + +export interface RevertInterface extends Interface { + getFunction(nameOrSignature: "doRevert"): FunctionFragment; + + encodeFunctionData(functionFragment: "doRevert", values?: undefined): string; + + decodeFunctionResult(functionFragment: "doRevert", data: BytesLike): Result; +} + +export interface Revert extends BaseContract { + connect(runner?: ContractRunner | null): Revert; + waitForDeployment(): Promise; + + interface: RevertInterface; + + queryFilter( + event: TCEvent, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + queryFilter( + filter: TypedDeferredTopicFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + + on( + event: TCEvent, + listener: TypedListener + ): Promise; + on( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + once( + event: TCEvent, + listener: TypedListener + ): Promise; + once( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + listeners( + event: TCEvent + ): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners( + event?: TCEvent + ): Promise; + + doRevert: TypedContractMethod<[], [void], "nonpayable">; + + getFunction( + key: string | FunctionFragment + ): T; + + getFunction( + nameOrSignature: "doRevert" + ): TypedContractMethod<[], [void], "nonpayable">; + + filters: {}; +} diff --git a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/common.ts b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/common.ts new file mode 100644 index 000000000000..56b5f21e9c1c --- /dev/null +++ b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/common.ts @@ -0,0 +1,131 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + FunctionFragment, + Typed, + EventFragment, + ContractTransaction, + ContractTransactionResponse, + DeferredTopicFilter, + EventLog, + TransactionRequest, + LogDescription, +} from "ethers"; + +export interface TypedDeferredTopicFilter<_TCEvent extends TypedContractEvent> + extends DeferredTopicFilter {} + +export interface TypedContractEvent< + InputTuple extends Array = any, + OutputTuple extends Array = any, + OutputObject = any +> { + (...args: Partial): TypedDeferredTopicFilter< + TypedContractEvent + >; + name: string; + fragment: EventFragment; + getFragment(...args: Partial): EventFragment; +} + +type __TypechainAOutputTuple = T extends TypedContractEvent< + infer _U, + infer W +> + ? W + : never; +type __TypechainOutputObject = T extends TypedContractEvent< + infer _U, + infer _W, + infer V +> + ? V + : never; + +export interface TypedEventLog + extends Omit { + args: __TypechainAOutputTuple & __TypechainOutputObject; +} + +export interface TypedLogDescription + extends Omit { + args: __TypechainAOutputTuple & __TypechainOutputObject; +} + +export type TypedListener = ( + ...listenerArg: [ + ...__TypechainAOutputTuple, + TypedEventLog, + ...undefined[] + ] +) => void; + +export type MinEthersFactory = { + deploy(...a: ARGS[]): Promise; +}; + +export type GetContractTypeFromFactory = F extends MinEthersFactory< + infer C, + any +> + ? C + : never; +export type GetARGsTypeFromFactory = F extends MinEthersFactory + ? Parameters + : never; + +export type StateMutability = "nonpayable" | "payable" | "view"; + +export type BaseOverrides = Omit; +export type NonPayableOverrides = Omit< + BaseOverrides, + "value" | "blockTag" | "enableCcipRead" +>; +export type PayableOverrides = Omit< + BaseOverrides, + "blockTag" | "enableCcipRead" +>; +export type ViewOverrides = Omit; +export type Overrides = S extends "nonpayable" + ? NonPayableOverrides + : S extends "payable" + ? PayableOverrides + : ViewOverrides; + +export type PostfixOverrides, S extends StateMutability> = + | A + | [...A, Overrides]; +export type ContractMethodArgs< + A extends Array, + S extends StateMutability +> = PostfixOverrides<{ [I in keyof A]-?: A[I] | Typed }, S>; + +export type DefaultReturnType = R extends Array ? R[0] : R; + +// export interface ContractMethod = Array, R = any, D extends R | ContractTransactionResponse = R | ContractTransactionResponse> { +export interface TypedContractMethod< + A extends Array = Array, + R = any, + S extends StateMutability = "payable" +> { + (...args: ContractMethodArgs): S extends "view" + ? Promise> + : Promise; + + name: string; + + fragment: FunctionFragment; + + getFragment(...args: ContractMethodArgs): FunctionFragment; + + populateTransaction( + ...args: ContractMethodArgs + ): Promise; + staticCall( + ...args: ContractMethodArgs + ): Promise>; + send(...args: ContractMethodArgs): Promise; + estimateGas(...args: ContractMethodArgs): Promise; + staticCallResult(...args: ContractMethodArgs): Promise; +} diff --git a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/Event__factory.ts b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/Event__factory.ts new file mode 100644 index 000000000000..76960c9cc393 --- /dev/null +++ b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/Event__factory.ts @@ -0,0 +1,51 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Interface, type ContractRunner } from "ethers"; +import type { Event, EventInterface } from "../Event"; + +const _abi = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "sender", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256", + }, + { + indexed: false, + internalType: "string", + name: "message", + type: "string", + }, + ], + name: "ExampleEvent", + type: "event", + }, + { + inputs: [], + name: "triggerEvent", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, +] as const; + +export class Event__factory { + static readonly abi = _abi; + static createInterface(): EventInterface { + return new Interface(_abi) as EventInterface; + } + static connect(address: string, runner?: ContractRunner | null): Event { + return new Contract(address, _abi, runner) as unknown as Event; + } +} diff --git a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/PiggyBank__factory.ts b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/PiggyBank__factory.ts new file mode 100644 index 000000000000..2ca11661cc0a --- /dev/null +++ b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/PiggyBank__factory.ts @@ -0,0 +1,82 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Interface, type ContractRunner } from "ethers"; +import type { PiggyBank, PiggyBankInterface } from "../PiggyBank"; + +const _abi = [ + { + inputs: [], + stateMutability: "nonpayable", + type: "constructor", + }, + { + inputs: [], + name: "deposit", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "payable", + type: "function", + }, + { + inputs: [], + name: "getDeposit", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "owner", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "withdrawAmount", + type: "uint256", + }, + ], + name: "withdraw", + outputs: [ + { + internalType: "uint256", + name: "remainingBal", + type: "uint256", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, +] as const; + +export class PiggyBank__factory { + static readonly abi = _abi; + static createInterface(): PiggyBankInterface { + return new Interface(_abi) as PiggyBankInterface; + } + static connect(address: string, runner?: ContractRunner | null): PiggyBank { + return new Contract(address, _abi, runner) as unknown as PiggyBank; + } +} diff --git a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/Revert__factory.ts b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/Revert__factory.ts new file mode 100644 index 000000000000..7f18d3c38a0b --- /dev/null +++ b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/Revert__factory.ts @@ -0,0 +1,31 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Interface, type ContractRunner } from "ethers"; +import type { Revert, RevertInterface } from "../Revert"; + +const _abi = [ + { + inputs: [], + stateMutability: "nonpayable", + type: "constructor", + }, + { + inputs: [], + name: "doRevert", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, +] as const; + +export class Revert__factory { + static readonly abi = _abi; + static createInterface(): RevertInterface { + return new Interface(_abi) as RevertInterface; + } + static connect(address: string, runner?: ContractRunner | null): Revert { + return new Contract(address, _abi, runner) as unknown as Revert; + } +} diff --git a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/index.ts b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/index.ts new file mode 100644 index 000000000000..2c6aa6766efb --- /dev/null +++ b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/index.ts @@ -0,0 +1,6 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export { Event__factory } from "./Event__factory"; +export { PiggyBank__factory } from "./PiggyBank__factory"; +export { Revert__factory } from "./Revert__factory"; diff --git a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/index.ts b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/index.ts new file mode 100644 index 000000000000..1a0aab37c057 --- /dev/null +++ b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/index.ts @@ -0,0 +1,10 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export type { Event } from "./Event"; +export type { PiggyBank } from "./PiggyBank"; +export type { Revert } from "./Revert"; +export * as factories from "./factories"; +export { Event__factory } from "./factories/Event__factory"; +export { PiggyBank__factory } from "./factories/PiggyBank__factory"; +export { Revert__factory } from "./factories/Revert__factory"; diff --git a/substrate/frame/revive/rpc/examples/package.json b/substrate/frame/revive/rpc/examples/package.json deleted file mode 100644 index 37d819aaa481..000000000000 --- a/substrate/frame/revive/rpc/examples/package.json +++ /dev/null @@ -1 +0,0 @@ -{ "dependencies": { "@parity/revive": "^0.0.5" } } \ No newline at end of file From 0c0b1101c91b92d6c0db2af7a644f0f7edd85955 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Wed, 13 Nov 2024 20:52:36 +0100 Subject: [PATCH 03/14] fix --- .../revive/rpc/examples/js/src/piggy-bank.ts | 5 +- substrate/frame/revive/src/exec.rs | 144 +++++++++--------- substrate/frame/revive/src/lib.rs | 29 +++- 3 files changed, 102 insertions(+), 76 deletions(-) diff --git a/substrate/frame/revive/rpc/examples/js/src/piggy-bank.ts b/substrate/frame/revive/rpc/examples/js/src/piggy-bank.ts index aaaac2dc9e18..7a8edbde3662 100644 --- a/substrate/frame/revive/rpc/examples/js/src/piggy-bank.ts +++ b/substrate/frame/revive/rpc/examples/js/src/piggy-bank.ts @@ -1,4 +1,5 @@ import { provider, call, getContract, deploy } from './lib.ts' +import { parseEther } from 'ethers' import { PiggyBank } from '../types/ethers-contracts/PiggyBank' try { @@ -7,14 +8,14 @@ try { const address = await contract.getAddress() let receipt = await call('deposit', address, abi, [], { - value: 10_000_000_000n, + value: parseEther('10.0'), }) console.log('Deposit receipt:', receipt?.status) console.log(`Contract balance: ${await provider.getBalance(address)}`) console.log('deposit: ', await contract.getDeposit()) - receipt = await call('withdraw', address, abi, [2_000_000_000n]) + receipt = await call('withdraw', address, abi, [parseEther('5.0')]) console.log('Withdraw receipt:', receipt?.status) console.log(`Contract balance: ${await provider.getBalance(address)}`) console.log('deposit: ', await contract.getDeposit()) diff --git a/substrate/frame/revive/src/exec.rs b/substrate/frame/revive/src/exec.rs index 4f90b41b0de5..46fd2292062e 100644 --- a/substrate/frame/revive/src/exec.rs +++ b/substrate/frame/revive/src/exec.rs @@ -569,8 +569,8 @@ struct Frame { account_id: T::AccountId, /// The cached in-storage data of the contract. contract_info: CachedContract, - /// The amount of balance transferred by the caller as part of the call. - value_transferred: BalanceOf, + /// The EVM balance transferred by the caller as part of the call. + value_transferred: U256, /// Determines whether this is a call or instantiate frame. entry_point: ExportedFunction, /// The gas meter capped to the supplied gas limit. @@ -757,7 +757,7 @@ where dest: H160, gas_meter: &'a mut GasMeter, storage_meter: &'a mut storage::meter::Meter, - value: BalanceOf, + value: U256, input_data: Vec, debug_message: Option<&'a mut DebugBuffer>, ) -> ExecResult { @@ -791,7 +791,7 @@ where executable: E, gas_meter: &'a mut GasMeter, storage_meter: &'a mut storage::meter::Meter, - value: BalanceOf, + value: U256, input_data: Vec, salt: Option<&[u8; 32]>, debug_message: Option<&'a mut DebugBuffer>, @@ -850,7 +850,7 @@ where origin: Origin, gas_meter: &'a mut GasMeter, storage_meter: &'a mut storage::meter::Meter, - value: BalanceOf, + value: U256, debug_message: Option<&'a mut DebugBuffer>, ) -> Result, ExecError> { origin.ensure_mapped()?; @@ -890,7 +890,7 @@ where /// not initialized, yet. fn new_frame( frame_args: FrameArgs, - value_transferred: BalanceOf, + value_transferred: U256, gas_meter: &mut GasMeter, gas_limit: Weight, storage_meter: &mut storage::meter::GenericMeter, @@ -975,7 +975,7 @@ where fn push_frame( &mut self, frame_args: FrameArgs, - value_transferred: BalanceOf, + value_transferred: U256, gas_limit: Weight, deposit_limit: BalanceOf, read_only: bool, @@ -1282,8 +1282,9 @@ where origin: &Origin, from: &T::AccountId, to: &T::AccountId, - value: BalanceOf, + value: U256, ) -> ExecResult { + let value = crate::Pallet::::convert_evm_to_native(value)?; if value.is_zero() { return Ok(Default::default()); } @@ -1311,7 +1312,7 @@ where origin: &Origin, from: &Origin, to: &T::AccountId, - value: BalanceOf, + value: U256, ) -> ExecResult { // If the from address is root there is no account to transfer from, and therefore we can't // take any `value` other than 0. @@ -1358,7 +1359,11 @@ where /// Returns the *free* balance of the supplied AccountId. fn account_balance(&self, who: &T::AccountId) -> U256 { - T::Currency::reducible_balance(who, Preservation::Preserve, Fortitude::Polite).into() + crate::Pallet::::convert_native_to_evm(T::Currency::reducible_balance( + who, + Preservation::Preserve, + Fortitude::Polite, + )) } /// Certain APIs, e.g. `{set,get}_immutable_data` behave differently depending @@ -2066,7 +2071,7 @@ mod tests { BOB_ADDR, &mut gas_meter, &mut storage_meter, - value, + value.into(), vec![], None, ), @@ -2153,7 +2158,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - value, + value.into(), vec![], None, ) @@ -2191,7 +2196,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - value, + value.into(), vec![], None, ) @@ -2223,7 +2228,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 55, + 55u64.into(), vec![], None, ) @@ -2272,7 +2277,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![], None, ); @@ -2301,7 +2306,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![], None, ); @@ -2330,7 +2335,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![1, 2, 3, 4], None, ); @@ -2365,7 +2370,7 @@ mod tests { executable, &mut gas_meter, &mut storage_meter, - min_balance, + min_balance.into(), vec![1, 2, 3, 4], Some(&[0; 32]), None, @@ -2420,7 +2425,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - value, + value.into(), vec![], None, ); @@ -2484,7 +2489,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![], None, ); @@ -2549,7 +2554,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![], None, ); @@ -2581,7 +2586,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![], None, ); @@ -2618,7 +2623,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![0], None, ); @@ -2644,7 +2649,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![0], None, ); @@ -2688,7 +2693,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![0], None, ); @@ -2714,7 +2719,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![0], None, ); @@ -2740,7 +2745,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 1, + 1u64.into(), vec![0], None, ); @@ -2784,7 +2789,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![0], None, ); @@ -2829,7 +2834,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![], None, ); @@ -2854,7 +2859,7 @@ mod tests { executable, &mut gas_meter, &mut storage_meter, - 0, // <- zero value + U256::zero(), // <- zero value vec![], Some(&[0; 32]), None, @@ -2889,8 +2894,7 @@ mod tests { executable, &mut gas_meter, &mut storage_meter, - - min_balance, + min_balance.into(), vec![], Some(&[0 ;32]), None, @@ -2945,7 +2949,7 @@ mod tests { &mut gas_meter, &mut storage_meter, - min_balance, + min_balance.into(), vec![], Some(&[0; 32]), None, @@ -3010,7 +3014,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - min_balance * 10, + (min_balance * 10).into(), vec![], None, ), @@ -3090,7 +3094,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![], None, ), @@ -3132,7 +3136,7 @@ mod tests { executable, &mut gas_meter, &mut storage_meter, - 100, + 100u64.into(), vec![], Some(&[0; 32]), None, @@ -3197,7 +3201,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![0], None, ); @@ -3258,7 +3262,7 @@ mod tests { executable, &mut gas_meter, &mut storage_meter, - 10, + 10u64.into(), vec![], Some(&[0; 32]), None, @@ -3305,7 +3309,7 @@ mod tests { BOB_ADDR, &mut gas_meter, &mut storage_meter, - 0, + U256::zero(), vec![], None, ) @@ -3336,7 +3340,7 @@ mod tests { BOB_ADDR, &mut gas_meter, &mut storage_meter, - 0, + U256::zero(), vec![], Some(&mut debug_buffer), ) @@ -3369,7 +3373,7 @@ mod tests { BOB_ADDR, &mut gas_meter, &mut storage_meter, - 0, + U256::zero(), vec![], Some(&mut debug_buffer), ); @@ -3402,7 +3406,7 @@ mod tests { BOB_ADDR, &mut gas_meter, &mut storage_meter, - 0, + U256::zero(), vec![], Some(&mut debug_buf_after), ) @@ -3435,7 +3439,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), CHARLIE_ADDR.as_bytes().to_vec(), None, )); @@ -3447,7 +3451,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), BOB_ADDR.as_bytes().to_vec(), None, ) @@ -3497,7 +3501,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![0], None, ) @@ -3531,7 +3535,7 @@ mod tests { BOB_ADDR, &mut gas_meter, &mut storage_meter, - 0, + U256::zero(), vec![], None, ) @@ -3615,7 +3619,7 @@ mod tests { BOB_ADDR, &mut gas_meter, &mut storage_meter, - 0, + U256::zero(), vec![], None, ) @@ -3740,7 +3744,7 @@ mod tests { fail_executable, &mut gas_meter, &mut storage_meter, - min_balance * 100, + (min_balance * 100).into(), vec![], Some(&[0; 32]), None, @@ -3753,7 +3757,7 @@ mod tests { success_executable, &mut gas_meter, &mut storage_meter, - min_balance * 100, + (min_balance * 100).into(), vec![], Some(&[0; 32]), None, @@ -3765,7 +3769,7 @@ mod tests { succ_fail_executable, &mut gas_meter, &mut storage_meter, - min_balance * 200, + (min_balance * 200).into(), vec![], Some(&[0; 32]), None, @@ -3777,7 +3781,7 @@ mod tests { succ_succ_executable, &mut gas_meter, &mut storage_meter, - min_balance * 200, + (min_balance * 200).into(), vec![], Some(&[0; 32]), None, @@ -3846,7 +3850,7 @@ mod tests { BOB_ADDR, &mut gas_meter, &mut storage_meter, - 0, + U256::zero(), vec![], None, )); @@ -3957,7 +3961,7 @@ mod tests { BOB_ADDR, &mut gas_meter, &mut storage_meter, - 0, + U256::zero(), vec![], None, )); @@ -3996,7 +4000,7 @@ mod tests { BOB_ADDR, &mut gas_meter, &mut storage_meter, - 0, + U256::zero(), vec![], None, )); @@ -4035,7 +4039,7 @@ mod tests { BOB_ADDR, &mut gas_meter, &mut storage_meter, - 0, + U256::zero(), vec![], None, )); @@ -4088,7 +4092,7 @@ mod tests { BOB_ADDR, &mut gas_meter, &mut storage_meter, - 0, + U256::zero(), vec![], None, )); @@ -4144,7 +4148,7 @@ mod tests { BOB_ADDR, &mut gas_meter, &mut storage_meter, - 0, + U256::zero(), vec![], None, )); @@ -4219,7 +4223,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![], None, )); @@ -4289,7 +4293,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![0], None, ); @@ -4327,7 +4331,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![], None, )); @@ -4389,7 +4393,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![0], None, ); @@ -4422,7 +4426,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![], None, ); @@ -4505,7 +4509,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![], None, ) @@ -4573,7 +4577,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![0], None, ); @@ -4639,7 +4643,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![], None, ); @@ -4690,7 +4694,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![], None, ) @@ -4761,7 +4765,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![], None, ) @@ -4807,7 +4811,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![], None, ) @@ -4851,7 +4855,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![], None, ) @@ -4906,7 +4910,7 @@ mod tests { BOB_ADDR, &mut GasMeter::::new(GAS_LIMIT), &mut storage_meter, - 0, + U256::zero(), vec![0], None, ), diff --git a/substrate/frame/revive/src/lib.rs b/substrate/frame/revive/src/lib.rs index e931976ec4f4..a1fd43841fea 100644 --- a/substrate/frame/revive/src/lib.rs +++ b/substrate/frame/revive/src/lib.rs @@ -73,7 +73,7 @@ use pallet_transaction_payment::OnChargeTransaction; use scale_info::TypeInfo; use sp_core::{H160, H256, U256}; use sp_runtime::{ - traits::{BadOrigin, Convert, Dispatchable, Saturating}, + traits::{BadOrigin, Convert, Dispatchable, Saturating, Zero}, DispatchError, }; @@ -379,7 +379,7 @@ pub mod pallet { type RuntimeMemory = ConstU32<{ 128 * 1024 * 1024 }>; type PVFMemory = ConstU32<{ 512 * 1024 * 1024 }>; type ChainId = ConstU64<0>; - type NativeToEthRatio = ConstU32<1_000_000>; + type NativeToEthRatio = ConstU32<1>; } } @@ -561,6 +561,8 @@ pub mod pallet { ExecutionFailed, /// Failed to convert a U256 to a Balance. BalanceConversionFailed, + /// Failed to convert an EVM balance to a native balance. + DecimalPrecisionLoss, /// Immutable data can only be set during deploys and only be read during calls. /// Additionally, it is only valid to set the data once and it must not be empty. InvalidImmutableAccess, @@ -1115,7 +1117,7 @@ where dest, &mut gas_meter, &mut storage_meter, - value, + Self::convert_native_to_evm(value), data, debug_message.as_mut(), )?; @@ -1180,7 +1182,7 @@ where executable, &mut gas_meter, &mut storage_meter, - value, + Self::convert_native_to_evm(value), data, salt.as_ref(), debug_message.as_mut(), @@ -1437,6 +1439,25 @@ where .and_then(|r| r) }) } + + /// Convert a native balance to EVM balance. + pub fn convert_native_to_evm(value: BalanceOf) -> U256 { + value.into().saturating_mul(T::NativeToEthRatio::get().into()) + } + + /// Convert an EVM balance to a native balance. + pub fn convert_evm_to_native(value: U256) -> Result, Error> { + if value.is_zero() { + return Ok(Zero::zero()) + } + let ratio = T::NativeToEthRatio::get().into(); + let res = value.checked_div(ratio).expect("divisor is non-zero; qed"); + if res.saturating_mul(ratio) == value { + res.try_into().map_err(|_| Error::::BalanceConversionFailed) + } else { + Err(Error::::DecimalPrecisionLoss) + } + } } impl Pallet { From f2bb256ed5d29c9ea8e554beda6eb0821f0f0298 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Wed, 13 Nov 2024 19:57:08 +0000 Subject: [PATCH 04/14] Update from pgherveou running command 'prdoc --audience runtime_dev --bump minor' --- prdoc/pr_6466.prdoc | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 prdoc/pr_6466.prdoc diff --git a/prdoc/pr_6466.prdoc b/prdoc/pr_6466.prdoc new file mode 100644 index 000000000000..0faa6afc8005 --- /dev/null +++ b/prdoc/pr_6466.prdoc @@ -0,0 +1,12 @@ +title: '[pallet-revive] add piggy-bank sol example' +doc: +- audience: Runtime Dev + description: |- + This PR update the pallet to use the EVM 18 decimal balance in contracts call and host functions instead of the native balance. + + It also updates the js example to add the piggy-bank solidity contract that expose the problem +crates: +- name: pallet-revive-eth-rpc + bump: minor +- name: pallet-revive + bump: minor From 18344c8adaf1f84e0c8270054c61875e6d50cbd4 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Wed, 13 Nov 2024 21:01:43 +0100 Subject: [PATCH 05/14] lint --- .../frame/revive/rpc/examples/js/src/lib.ts | 4 +- .../js/types/ethers-contracts/Event.ts | 216 ++++++++---------- .../js/types/ethers-contracts/PiggyBank.ts | 196 +++++++--------- .../js/types/ethers-contracts/Revert.ts | 118 +++++----- .../js/types/ethers-contracts/common.ts | 165 ++++++------- .../factories/Event__factory.ts | 84 +++---- .../factories/PiggyBank__factory.ts | 146 ++++++------ .../factories/Revert__factory.ts | 44 ++-- .../types/ethers-contracts/factories/index.ts | 6 +- .../js/types/ethers-contracts/index.ts | 14 +- 10 files changed, 457 insertions(+), 536 deletions(-) diff --git a/substrate/frame/revive/rpc/examples/js/src/lib.ts b/substrate/frame/revive/rpc/examples/js/src/lib.ts index 9ac0491dd2b7..975d8faf15b3 100644 --- a/substrate/frame/revive/rpc/examples/js/src/lib.ts +++ b/substrate/frame/revive/rpc/examples/js/src/lib.ts @@ -59,8 +59,8 @@ export const provider = new JsonRpcProvider( westend ? 'https://westend-asset-hub-eth-rpc.polkadot.io' : geth - ? 'http://localhost:8546' - : 'http://localhost:8545' + ? 'http://localhost:8546' + : 'http://localhost:8545' ) export const signer = privateKey ? new Wallet(privateKey, provider) : await provider.getSigner() diff --git a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/Event.ts b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/Event.ts index 50e4d8344c92..d65f953969f0 100644 --- a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/Event.ts +++ b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/Event.ts @@ -2,132 +2,116 @@ /* tslint:disable */ /* eslint-disable */ import type { - BaseContract, - BigNumberish, - BytesLike, - FunctionFragment, - Result, - Interface, - EventFragment, - AddressLike, - ContractRunner, - ContractMethod, - Listener, -} from "ethers"; + BaseContract, + BigNumberish, + BytesLike, + FunctionFragment, + Result, + Interface, + EventFragment, + AddressLike, + ContractRunner, + ContractMethod, + Listener, +} from 'ethers' import type { - TypedContractEvent, - TypedDeferredTopicFilter, - TypedEventLog, - TypedLogDescription, - TypedListener, - TypedContractMethod, -} from "./common"; + TypedContractEvent, + TypedDeferredTopicFilter, + TypedEventLog, + TypedLogDescription, + TypedListener, + TypedContractMethod, +} from './common' export interface EventInterface extends Interface { - getFunction(nameOrSignature: "triggerEvent"): FunctionFragment; + getFunction(nameOrSignature: 'triggerEvent'): FunctionFragment - getEvent(nameOrSignatureOrTopic: "ExampleEvent"): EventFragment; + getEvent(nameOrSignatureOrTopic: 'ExampleEvent'): EventFragment - encodeFunctionData( - functionFragment: "triggerEvent", - values?: undefined - ): string; + encodeFunctionData(functionFragment: 'triggerEvent', values?: undefined): string - decodeFunctionResult( - functionFragment: "triggerEvent", - data: BytesLike - ): Result; + decodeFunctionResult(functionFragment: 'triggerEvent', data: BytesLike): Result } export namespace ExampleEventEvent { - export type InputTuple = [ - sender: AddressLike, - value: BigNumberish, - message: string - ]; - export type OutputTuple = [sender: string, value: bigint, message: string]; - export interface OutputObject { - sender: string; - value: bigint; - message: string; - } - export type Event = TypedContractEvent; - export type Filter = TypedDeferredTopicFilter; - export type Log = TypedEventLog; - export type LogDescription = TypedLogDescription; + export type InputTuple = [sender: AddressLike, value: BigNumberish, message: string] + export type OutputTuple = [sender: string, value: bigint, message: string] + export interface OutputObject { + sender: string + value: bigint + message: string + } + export type Event = TypedContractEvent + export type Filter = TypedDeferredTopicFilter + export type Log = TypedEventLog + export type LogDescription = TypedLogDescription } export interface Event extends BaseContract { - connect(runner?: ContractRunner | null): Event; - waitForDeployment(): Promise; - - interface: EventInterface; - - queryFilter( - event: TCEvent, - fromBlockOrBlockhash?: string | number | undefined, - toBlock?: string | number | undefined - ): Promise>>; - queryFilter( - filter: TypedDeferredTopicFilter, - fromBlockOrBlockhash?: string | number | undefined, - toBlock?: string | number | undefined - ): Promise>>; - - on( - event: TCEvent, - listener: TypedListener - ): Promise; - on( - filter: TypedDeferredTopicFilter, - listener: TypedListener - ): Promise; - - once( - event: TCEvent, - listener: TypedListener - ): Promise; - once( - filter: TypedDeferredTopicFilter, - listener: TypedListener - ): Promise; - - listeners( - event: TCEvent - ): Promise>>; - listeners(eventName?: string): Promise>; - removeAllListeners( - event?: TCEvent - ): Promise; - - triggerEvent: TypedContractMethod<[], [void], "nonpayable">; - - getFunction( - key: string | FunctionFragment - ): T; - - getFunction( - nameOrSignature: "triggerEvent" - ): TypedContractMethod<[], [void], "nonpayable">; - - getEvent( - key: "ExampleEvent" - ): TypedContractEvent< - ExampleEventEvent.InputTuple, - ExampleEventEvent.OutputTuple, - ExampleEventEvent.OutputObject - >; - - filters: { - "ExampleEvent(address,uint256,string)": TypedContractEvent< - ExampleEventEvent.InputTuple, - ExampleEventEvent.OutputTuple, - ExampleEventEvent.OutputObject - >; - ExampleEvent: TypedContractEvent< - ExampleEventEvent.InputTuple, - ExampleEventEvent.OutputTuple, - ExampleEventEvent.OutputObject - >; - }; + connect(runner?: ContractRunner | null): Event + waitForDeployment(): Promise + + interface: EventInterface + + queryFilter( + event: TCEvent, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>> + queryFilter( + filter: TypedDeferredTopicFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>> + + on( + event: TCEvent, + listener: TypedListener + ): Promise + on( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise + + once( + event: TCEvent, + listener: TypedListener + ): Promise + once( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise + + listeners( + event: TCEvent + ): Promise>> + listeners(eventName?: string): Promise> + removeAllListeners(event?: TCEvent): Promise + + triggerEvent: TypedContractMethod<[], [void], 'nonpayable'> + + getFunction(key: string | FunctionFragment): T + + getFunction(nameOrSignature: 'triggerEvent'): TypedContractMethod<[], [void], 'nonpayable'> + + getEvent( + key: 'ExampleEvent' + ): TypedContractEvent< + ExampleEventEvent.InputTuple, + ExampleEventEvent.OutputTuple, + ExampleEventEvent.OutputObject + > + + filters: { + 'ExampleEvent(address,uint256,string)': TypedContractEvent< + ExampleEventEvent.InputTuple, + ExampleEventEvent.OutputTuple, + ExampleEventEvent.OutputObject + > + ExampleEvent: TypedContractEvent< + ExampleEventEvent.InputTuple, + ExampleEventEvent.OutputTuple, + ExampleEventEvent.OutputObject + > + } } diff --git a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/PiggyBank.ts b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/PiggyBank.ts index 9ba06338c0fc..ca137fcc8b30 100644 --- a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/PiggyBank.ts +++ b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/PiggyBank.ts @@ -2,121 +2,95 @@ /* tslint:disable */ /* eslint-disable */ import type { - BaseContract, - BigNumberish, - BytesLike, - FunctionFragment, - Result, - Interface, - ContractRunner, - ContractMethod, - Listener, -} from "ethers"; + BaseContract, + BigNumberish, + BytesLike, + FunctionFragment, + Result, + Interface, + ContractRunner, + ContractMethod, + Listener, +} from 'ethers' import type { - TypedContractEvent, - TypedDeferredTopicFilter, - TypedEventLog, - TypedListener, - TypedContractMethod, -} from "./common"; + TypedContractEvent, + TypedDeferredTopicFilter, + TypedEventLog, + TypedListener, + TypedContractMethod, +} from './common' export interface PiggyBankInterface extends Interface { - getFunction( - nameOrSignature: "deposit" | "getDeposit" | "owner" | "withdraw" - ): FunctionFragment; - - encodeFunctionData(functionFragment: "deposit", values?: undefined): string; - encodeFunctionData( - functionFragment: "getDeposit", - values?: undefined - ): string; - encodeFunctionData(functionFragment: "owner", values?: undefined): string; - encodeFunctionData( - functionFragment: "withdraw", - values: [BigNumberish] - ): string; - - decodeFunctionResult(functionFragment: "deposit", data: BytesLike): Result; - decodeFunctionResult(functionFragment: "getDeposit", data: BytesLike): Result; - decodeFunctionResult(functionFragment: "owner", data: BytesLike): Result; - decodeFunctionResult(functionFragment: "withdraw", data: BytesLike): Result; + getFunction(nameOrSignature: 'deposit' | 'getDeposit' | 'owner' | 'withdraw'): FunctionFragment + + encodeFunctionData(functionFragment: 'deposit', values?: undefined): string + encodeFunctionData(functionFragment: 'getDeposit', values?: undefined): string + encodeFunctionData(functionFragment: 'owner', values?: undefined): string + encodeFunctionData(functionFragment: 'withdraw', values: [BigNumberish]): string + + decodeFunctionResult(functionFragment: 'deposit', data: BytesLike): Result + decodeFunctionResult(functionFragment: 'getDeposit', data: BytesLike): Result + decodeFunctionResult(functionFragment: 'owner', data: BytesLike): Result + decodeFunctionResult(functionFragment: 'withdraw', data: BytesLike): Result } export interface PiggyBank extends BaseContract { - connect(runner?: ContractRunner | null): PiggyBank; - waitForDeployment(): Promise; - - interface: PiggyBankInterface; - - queryFilter( - event: TCEvent, - fromBlockOrBlockhash?: string | number | undefined, - toBlock?: string | number | undefined - ): Promise>>; - queryFilter( - filter: TypedDeferredTopicFilter, - fromBlockOrBlockhash?: string | number | undefined, - toBlock?: string | number | undefined - ): Promise>>; - - on( - event: TCEvent, - listener: TypedListener - ): Promise; - on( - filter: TypedDeferredTopicFilter, - listener: TypedListener - ): Promise; - - once( - event: TCEvent, - listener: TypedListener - ): Promise; - once( - filter: TypedDeferredTopicFilter, - listener: TypedListener - ): Promise; - - listeners( - event: TCEvent - ): Promise>>; - listeners(eventName?: string): Promise>; - removeAllListeners( - event?: TCEvent - ): Promise; - - deposit: TypedContractMethod<[], [bigint], "payable">; - - getDeposit: TypedContractMethod<[], [bigint], "view">; - - owner: TypedContractMethod<[], [string], "view">; - - withdraw: TypedContractMethod< - [withdrawAmount: BigNumberish], - [bigint], - "nonpayable" - >; - - getFunction( - key: string | FunctionFragment - ): T; - - getFunction( - nameOrSignature: "deposit" - ): TypedContractMethod<[], [bigint], "payable">; - getFunction( - nameOrSignature: "getDeposit" - ): TypedContractMethod<[], [bigint], "view">; - getFunction( - nameOrSignature: "owner" - ): TypedContractMethod<[], [string], "view">; - getFunction( - nameOrSignature: "withdraw" - ): TypedContractMethod< - [withdrawAmount: BigNumberish], - [bigint], - "nonpayable" - >; - - filters: {}; + connect(runner?: ContractRunner | null): PiggyBank + waitForDeployment(): Promise + + interface: PiggyBankInterface + + queryFilter( + event: TCEvent, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>> + queryFilter( + filter: TypedDeferredTopicFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>> + + on( + event: TCEvent, + listener: TypedListener + ): Promise + on( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise + + once( + event: TCEvent, + listener: TypedListener + ): Promise + once( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise + + listeners( + event: TCEvent + ): Promise>> + listeners(eventName?: string): Promise> + removeAllListeners(event?: TCEvent): Promise + + deposit: TypedContractMethod<[], [bigint], 'payable'> + + getDeposit: TypedContractMethod<[], [bigint], 'view'> + + owner: TypedContractMethod<[], [string], 'view'> + + withdraw: TypedContractMethod<[withdrawAmount: BigNumberish], [bigint], 'nonpayable'> + + getFunction(key: string | FunctionFragment): T + + getFunction(nameOrSignature: 'deposit'): TypedContractMethod<[], [bigint], 'payable'> + getFunction(nameOrSignature: 'getDeposit'): TypedContractMethod<[], [bigint], 'view'> + getFunction(nameOrSignature: 'owner'): TypedContractMethod<[], [string], 'view'> + getFunction( + nameOrSignature: 'withdraw' + ): TypedContractMethod<[withdrawAmount: BigNumberish], [bigint], 'nonpayable'> + + filters: {} } diff --git a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/Revert.ts b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/Revert.ts index 4478811fb537..ad6e23b38a65 100644 --- a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/Revert.ts +++ b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/Revert.ts @@ -2,83 +2,77 @@ /* tslint:disable */ /* eslint-disable */ import type { - BaseContract, - BytesLike, - FunctionFragment, - Result, - Interface, - ContractRunner, - ContractMethod, - Listener, -} from "ethers"; + BaseContract, + BytesLike, + FunctionFragment, + Result, + Interface, + ContractRunner, + ContractMethod, + Listener, +} from 'ethers' import type { - TypedContractEvent, - TypedDeferredTopicFilter, - TypedEventLog, - TypedListener, - TypedContractMethod, -} from "./common"; + TypedContractEvent, + TypedDeferredTopicFilter, + TypedEventLog, + TypedListener, + TypedContractMethod, +} from './common' export interface RevertInterface extends Interface { - getFunction(nameOrSignature: "doRevert"): FunctionFragment; + getFunction(nameOrSignature: 'doRevert'): FunctionFragment - encodeFunctionData(functionFragment: "doRevert", values?: undefined): string; + encodeFunctionData(functionFragment: 'doRevert', values?: undefined): string - decodeFunctionResult(functionFragment: "doRevert", data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'doRevert', data: BytesLike): Result } export interface Revert extends BaseContract { - connect(runner?: ContractRunner | null): Revert; - waitForDeployment(): Promise; + connect(runner?: ContractRunner | null): Revert + waitForDeployment(): Promise - interface: RevertInterface; + interface: RevertInterface - queryFilter( - event: TCEvent, - fromBlockOrBlockhash?: string | number | undefined, - toBlock?: string | number | undefined - ): Promise>>; - queryFilter( - filter: TypedDeferredTopicFilter, - fromBlockOrBlockhash?: string | number | undefined, - toBlock?: string | number | undefined - ): Promise>>; + queryFilter( + event: TCEvent, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>> + queryFilter( + filter: TypedDeferredTopicFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>> - on( - event: TCEvent, - listener: TypedListener - ): Promise; - on( - filter: TypedDeferredTopicFilter, - listener: TypedListener - ): Promise; + on( + event: TCEvent, + listener: TypedListener + ): Promise + on( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise - once( - event: TCEvent, - listener: TypedListener - ): Promise; - once( - filter: TypedDeferredTopicFilter, - listener: TypedListener - ): Promise; + once( + event: TCEvent, + listener: TypedListener + ): Promise + once( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise - listeners( - event: TCEvent - ): Promise>>; - listeners(eventName?: string): Promise>; - removeAllListeners( - event?: TCEvent - ): Promise; + listeners( + event: TCEvent + ): Promise>> + listeners(eventName?: string): Promise> + removeAllListeners(event?: TCEvent): Promise - doRevert: TypedContractMethod<[], [void], "nonpayable">; + doRevert: TypedContractMethod<[], [void], 'nonpayable'> - getFunction( - key: string | FunctionFragment - ): T; + getFunction(key: string | FunctionFragment): T - getFunction( - nameOrSignature: "doRevert" - ): TypedContractMethod<[], [void], "nonpayable">; + getFunction(nameOrSignature: 'doRevert'): TypedContractMethod<[], [void], 'nonpayable'> - filters: {}; + filters: {} } diff --git a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/common.ts b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/common.ts index 56b5f21e9c1c..247b9468ece2 100644 --- a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/common.ts +++ b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/common.ts @@ -2,130 +2,99 @@ /* tslint:disable */ /* eslint-disable */ import type { - FunctionFragment, - Typed, - EventFragment, - ContractTransaction, - ContractTransactionResponse, - DeferredTopicFilter, - EventLog, - TransactionRequest, - LogDescription, -} from "ethers"; + FunctionFragment, + Typed, + EventFragment, + ContractTransaction, + ContractTransactionResponse, + DeferredTopicFilter, + EventLog, + TransactionRequest, + LogDescription, +} from 'ethers' export interface TypedDeferredTopicFilter<_TCEvent extends TypedContractEvent> - extends DeferredTopicFilter {} + extends DeferredTopicFilter {} export interface TypedContractEvent< - InputTuple extends Array = any, - OutputTuple extends Array = any, - OutputObject = any + InputTuple extends Array = any, + OutputTuple extends Array = any, + OutputObject = any, > { - (...args: Partial): TypedDeferredTopicFilter< - TypedContractEvent - >; - name: string; - fragment: EventFragment; - getFragment(...args: Partial): EventFragment; + ( + ...args: Partial + ): TypedDeferredTopicFilter> + name: string + fragment: EventFragment + getFragment(...args: Partial): EventFragment } -type __TypechainAOutputTuple = T extends TypedContractEvent< - infer _U, - infer W -> - ? W - : never; -type __TypechainOutputObject = T extends TypedContractEvent< - infer _U, - infer _W, - infer V -> - ? V - : never; +type __TypechainAOutputTuple = T extends TypedContractEvent ? W : never +type __TypechainOutputObject = + T extends TypedContractEvent ? V : never -export interface TypedEventLog - extends Omit { - args: __TypechainAOutputTuple & __TypechainOutputObject; +export interface TypedEventLog extends Omit { + args: __TypechainAOutputTuple & __TypechainOutputObject } export interface TypedLogDescription - extends Omit { - args: __TypechainAOutputTuple & __TypechainOutputObject; + extends Omit { + args: __TypechainAOutputTuple & __TypechainOutputObject } export type TypedListener = ( - ...listenerArg: [ - ...__TypechainAOutputTuple, - TypedEventLog, - ...undefined[] - ] -) => void; + ...listenerArg: [...__TypechainAOutputTuple, TypedEventLog, ...undefined[]] +) => void export type MinEthersFactory = { - deploy(...a: ARGS[]): Promise; -}; + deploy(...a: ARGS[]): Promise +} -export type GetContractTypeFromFactory = F extends MinEthersFactory< - infer C, - any -> - ? C - : never; -export type GetARGsTypeFromFactory = F extends MinEthersFactory - ? Parameters - : never; - -export type StateMutability = "nonpayable" | "payable" | "view"; - -export type BaseOverrides = Omit; -export type NonPayableOverrides = Omit< - BaseOverrides, - "value" | "blockTag" | "enableCcipRead" ->; -export type PayableOverrides = Omit< - BaseOverrides, - "blockTag" | "enableCcipRead" ->; -export type ViewOverrides = Omit; -export type Overrides = S extends "nonpayable" - ? NonPayableOverrides - : S extends "payable" - ? PayableOverrides - : ViewOverrides; +export type GetContractTypeFromFactory = F extends MinEthersFactory ? C : never +export type GetARGsTypeFromFactory = + F extends MinEthersFactory ? Parameters : never + +export type StateMutability = 'nonpayable' | 'payable' | 'view' + +export type BaseOverrides = Omit +export type NonPayableOverrides = Omit +export type PayableOverrides = Omit +export type ViewOverrides = Omit +export type Overrides = S extends 'nonpayable' + ? NonPayableOverrides + : S extends 'payable' + ? PayableOverrides + : ViewOverrides export type PostfixOverrides, S extends StateMutability> = - | A - | [...A, Overrides]; -export type ContractMethodArgs< - A extends Array, - S extends StateMutability -> = PostfixOverrides<{ [I in keyof A]-?: A[I] | Typed }, S>; + | A + | [...A, Overrides] +export type ContractMethodArgs, S extends StateMutability> = PostfixOverrides< + { [I in keyof A]-?: A[I] | Typed }, + S +> -export type DefaultReturnType = R extends Array ? R[0] : R; +export type DefaultReturnType = R extends Array ? R[0] : R // export interface ContractMethod = Array, R = any, D extends R | ContractTransactionResponse = R | ContractTransactionResponse> { export interface TypedContractMethod< - A extends Array = Array, - R = any, - S extends StateMutability = "payable" + A extends Array = Array, + R = any, + S extends StateMutability = 'payable', > { - (...args: ContractMethodArgs): S extends "view" - ? Promise> - : Promise; + ( + ...args: ContractMethodArgs + ): S extends 'view' ? Promise> : Promise - name: string; + name: string - fragment: FunctionFragment; + fragment: FunctionFragment - getFragment(...args: ContractMethodArgs): FunctionFragment; + getFragment(...args: ContractMethodArgs): FunctionFragment - populateTransaction( - ...args: ContractMethodArgs - ): Promise; - staticCall( - ...args: ContractMethodArgs - ): Promise>; - send(...args: ContractMethodArgs): Promise; - estimateGas(...args: ContractMethodArgs): Promise; - staticCallResult(...args: ContractMethodArgs): Promise; + populateTransaction(...args: ContractMethodArgs): Promise + staticCall(...args: ContractMethodArgs): Promise> + send(...args: ContractMethodArgs): Promise + estimateGas(...args: ContractMethodArgs): Promise + staticCallResult(...args: ContractMethodArgs): Promise } diff --git a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/Event__factory.ts b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/Event__factory.ts index 76960c9cc393..2e16b18a7ed8 100644 --- a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/Event__factory.ts +++ b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/Event__factory.ts @@ -2,50 +2,50 @@ /* tslint:disable */ /* eslint-disable */ -import { Contract, Interface, type ContractRunner } from "ethers"; -import type { Event, EventInterface } from "../Event"; +import { Contract, Interface, type ContractRunner } from 'ethers' +import type { Event, EventInterface } from '../Event' const _abi = [ - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "sender", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "value", - type: "uint256", - }, - { - indexed: false, - internalType: "string", - name: "message", - type: "string", - }, - ], - name: "ExampleEvent", - type: "event", - }, - { - inputs: [], - name: "triggerEvent", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, -] as const; + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'sender', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + { + indexed: false, + internalType: 'string', + name: 'message', + type: 'string', + }, + ], + name: 'ExampleEvent', + type: 'event', + }, + { + inputs: [], + name: 'triggerEvent', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const export class Event__factory { - static readonly abi = _abi; - static createInterface(): EventInterface { - return new Interface(_abi) as EventInterface; - } - static connect(address: string, runner?: ContractRunner | null): Event { - return new Contract(address, _abi, runner) as unknown as Event; - } + static readonly abi = _abi + static createInterface(): EventInterface { + return new Interface(_abi) as EventInterface + } + static connect(address: string, runner?: ContractRunner | null): Event { + return new Contract(address, _abi, runner) as unknown as Event + } } diff --git a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/PiggyBank__factory.ts b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/PiggyBank__factory.ts index 2ca11661cc0a..0efea80ed2dc 100644 --- a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/PiggyBank__factory.ts +++ b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/PiggyBank__factory.ts @@ -2,81 +2,81 @@ /* tslint:disable */ /* eslint-disable */ -import { Contract, Interface, type ContractRunner } from "ethers"; -import type { PiggyBank, PiggyBankInterface } from "../PiggyBank"; +import { Contract, Interface, type ContractRunner } from 'ethers' +import type { PiggyBank, PiggyBankInterface } from '../PiggyBank' const _abi = [ - { - inputs: [], - stateMutability: "nonpayable", - type: "constructor", - }, - { - inputs: [], - name: "deposit", - outputs: [ - { - internalType: "uint256", - name: "", - type: "uint256", - }, - ], - stateMutability: "payable", - type: "function", - }, - { - inputs: [], - name: "getDeposit", - outputs: [ - { - internalType: "uint256", - name: "", - type: "uint256", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "owner", - outputs: [ - { - internalType: "address", - name: "", - type: "address", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - internalType: "uint256", - name: "withdrawAmount", - type: "uint256", - }, - ], - name: "withdraw", - outputs: [ - { - internalType: "uint256", - name: "remainingBal", - type: "uint256", - }, - ], - stateMutability: "nonpayable", - type: "function", - }, -] as const; + { + inputs: [], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + inputs: [], + name: 'deposit', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [], + name: 'getDeposit', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'owner', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'withdrawAmount', + type: 'uint256', + }, + ], + name: 'withdraw', + outputs: [ + { + internalType: 'uint256', + name: 'remainingBal', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const export class PiggyBank__factory { - static readonly abi = _abi; - static createInterface(): PiggyBankInterface { - return new Interface(_abi) as PiggyBankInterface; - } - static connect(address: string, runner?: ContractRunner | null): PiggyBank { - return new Contract(address, _abi, runner) as unknown as PiggyBank; - } + static readonly abi = _abi + static createInterface(): PiggyBankInterface { + return new Interface(_abi) as PiggyBankInterface + } + static connect(address: string, runner?: ContractRunner | null): PiggyBank { + return new Contract(address, _abi, runner) as unknown as PiggyBank + } } diff --git a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/Revert__factory.ts b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/Revert__factory.ts index 7f18d3c38a0b..ece1c6b5426e 100644 --- a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/Revert__factory.ts +++ b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/Revert__factory.ts @@ -2,30 +2,30 @@ /* tslint:disable */ /* eslint-disable */ -import { Contract, Interface, type ContractRunner } from "ethers"; -import type { Revert, RevertInterface } from "../Revert"; +import { Contract, Interface, type ContractRunner } from 'ethers' +import type { Revert, RevertInterface } from '../Revert' const _abi = [ - { - inputs: [], - stateMutability: "nonpayable", - type: "constructor", - }, - { - inputs: [], - name: "doRevert", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, -] as const; + { + inputs: [], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + inputs: [], + name: 'doRevert', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const export class Revert__factory { - static readonly abi = _abi; - static createInterface(): RevertInterface { - return new Interface(_abi) as RevertInterface; - } - static connect(address: string, runner?: ContractRunner | null): Revert { - return new Contract(address, _abi, runner) as unknown as Revert; - } + static readonly abi = _abi + static createInterface(): RevertInterface { + return new Interface(_abi) as RevertInterface + } + static connect(address: string, runner?: ContractRunner | null): Revert { + return new Contract(address, _abi, runner) as unknown as Revert + } } diff --git a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/index.ts b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/index.ts index 2c6aa6766efb..67370dba411c 100644 --- a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/index.ts +++ b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/factories/index.ts @@ -1,6 +1,6 @@ /* Autogenerated file. Do not edit manually. */ /* tslint:disable */ /* eslint-disable */ -export { Event__factory } from "./Event__factory"; -export { PiggyBank__factory } from "./PiggyBank__factory"; -export { Revert__factory } from "./Revert__factory"; +export { Event__factory } from './Event__factory' +export { PiggyBank__factory } from './PiggyBank__factory' +export { Revert__factory } from './Revert__factory' diff --git a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/index.ts b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/index.ts index 1a0aab37c057..3e324e80dcb1 100644 --- a/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/index.ts +++ b/substrate/frame/revive/rpc/examples/js/types/ethers-contracts/index.ts @@ -1,10 +1,10 @@ /* Autogenerated file. Do not edit manually. */ /* tslint:disable */ /* eslint-disable */ -export type { Event } from "./Event"; -export type { PiggyBank } from "./PiggyBank"; -export type { Revert } from "./Revert"; -export * as factories from "./factories"; -export { Event__factory } from "./factories/Event__factory"; -export { PiggyBank__factory } from "./factories/PiggyBank__factory"; -export { Revert__factory } from "./factories/Revert__factory"; +export type { Event } from './Event' +export type { PiggyBank } from './PiggyBank' +export type { Revert } from './Revert' +export * as factories from './factories' +export { Event__factory } from './factories/Event__factory' +export { PiggyBank__factory } from './factories/PiggyBank__factory' +export { Revert__factory } from './factories/Revert__factory' From 58bedddd4bd52e3887e92591e3201ad9fe2696ea Mon Sep 17 00:00:00 2001 From: pgherveou Date: Wed, 13 Nov 2024 21:02:26 +0100 Subject: [PATCH 06/14] lint --- .../revive/rpc/examples/js/abi/event.json | 66 +- .../revive/rpc/examples/js/abi/piggyBank.json | 128 +-- .../revive/rpc/examples/js/abi/revert.json | 26 +- .../frame/revive/rpc/examples/js/index.html | 53 +- .../revive/rpc/examples/js/package-lock.json | 882 +++++++++--------- .../revive/rpc/examples/js/tsconfig.json | 38 +- 6 files changed, 601 insertions(+), 592 deletions(-) diff --git a/substrate/frame/revive/rpc/examples/js/abi/event.json b/substrate/frame/revive/rpc/examples/js/abi/event.json index a64c920c4068..d36089fbc84e 100644 --- a/substrate/frame/revive/rpc/examples/js/abi/event.json +++ b/substrate/frame/revive/rpc/examples/js/abi/event.json @@ -1,34 +1,34 @@ [ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "string", - "name": "message", - "type": "string" - } - ], - "name": "ExampleEvent", - "type": "event" - }, - { - "inputs": [], - "name": "triggerEvent", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] \ No newline at end of file + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "string", + "name": "message", + "type": "string" + } + ], + "name": "ExampleEvent", + "type": "event" + }, + { + "inputs": [], + "name": "triggerEvent", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/substrate/frame/revive/rpc/examples/js/abi/piggyBank.json b/substrate/frame/revive/rpc/examples/js/abi/piggyBank.json index e6655889e21a..2c2cfd5f7533 100644 --- a/substrate/frame/revive/rpc/examples/js/abi/piggyBank.json +++ b/substrate/frame/revive/rpc/examples/js/abi/piggyBank.json @@ -1,65 +1,65 @@ [ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "deposit", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "getDeposit", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "withdrawAmount", - "type": "uint256" - } - ], - "name": "withdraw", - "outputs": [ - { - "internalType": "uint256", - "name": "remainingBal", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - } -] \ No newline at end of file + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "deposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "getDeposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "withdrawAmount", + "type": "uint256" + } + ], + "name": "withdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "remainingBal", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/substrate/frame/revive/rpc/examples/js/abi/revert.json b/substrate/frame/revive/rpc/examples/js/abi/revert.json index 4a7f2342421a..be2945fcc0a5 100644 --- a/substrate/frame/revive/rpc/examples/js/abi/revert.json +++ b/substrate/frame/revive/rpc/examples/js/abi/revert.json @@ -1,14 +1,14 @@ [ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "doRevert", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] \ No newline at end of file + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "doRevert", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/substrate/frame/revive/rpc/examples/js/index.html b/substrate/frame/revive/rpc/examples/js/index.html index 052daf2787f6..97efebe180ea 100644 --- a/substrate/frame/revive/rpc/examples/js/index.html +++ b/substrate/frame/revive/rpc/examples/js/index.html @@ -1,29 +1,38 @@ - - - - - MetaMask Playground - - - - - + button { + display: block; + margin-bottom: 10px; + } + + + + + - + - - + + - - - + + + diff --git a/substrate/frame/revive/rpc/examples/js/package-lock.json b/substrate/frame/revive/rpc/examples/js/package-lock.json index f1453eae64cc..5c7db0abc936 100644 --- a/substrate/frame/revive/rpc/examples/js/package-lock.json +++ b/substrate/frame/revive/rpc/examples/js/package-lock.json @@ -1,443 +1,443 @@ { - "name": "demo", - "version": "0.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "demo", - "version": "0.0.0", - "dependencies": { - "ethers": "^6.13.1", - "solc": "^0.8.28" - }, - "devDependencies": { - "typescript": "^5.5.3", - "vite": "^5.4.8" - } - }, - "node_modules/@adraffy/ens-normalize": { - "version": "1.10.1", - "license": "MIT" - }, - "node_modules/@esbuild/linux-x64": { - "version": "0.21.5", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@noble/curves": { - "version": "1.2.0", - "license": "MIT", - "dependencies": { - "@noble/hashes": "1.3.2" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@noble/hashes": { - "version": "1.3.2", - "license": "MIT", - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.24.0", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.24.0", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@types/estree": { - "version": "1.0.6", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/node": { - "version": "18.15.13", - "license": "MIT" - }, - "node_modules/aes-js": { - "version": "4.0.0-beta.5", - "license": "MIT" - }, - "node_modules/command-exists": { - "version": "1.2.9", - "resolved": "https://registry.npmjs.org/command-exists/-/command-exists-1.2.9.tgz", - "integrity": "sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w==", - "license": "MIT" - }, - "node_modules/commander": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", - "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==", - "license": "MIT", - "engines": { - "node": ">= 12" - } - }, - "node_modules/esbuild": { - "version": "0.21.5", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "bin": { - "esbuild": "bin/esbuild" - }, - "engines": { - "node": ">=12" - }, - "optionalDependencies": { - "@esbuild/aix-ppc64": "0.21.5", - "@esbuild/android-arm": "0.21.5", - "@esbuild/android-arm64": "0.21.5", - "@esbuild/android-x64": "0.21.5", - "@esbuild/darwin-arm64": "0.21.5", - "@esbuild/darwin-x64": "0.21.5", - "@esbuild/freebsd-arm64": "0.21.5", - "@esbuild/freebsd-x64": "0.21.5", - "@esbuild/linux-arm": "0.21.5", - "@esbuild/linux-arm64": "0.21.5", - "@esbuild/linux-ia32": "0.21.5", - "@esbuild/linux-loong64": "0.21.5", - "@esbuild/linux-mips64el": "0.21.5", - "@esbuild/linux-ppc64": "0.21.5", - "@esbuild/linux-riscv64": "0.21.5", - "@esbuild/linux-s390x": "0.21.5", - "@esbuild/linux-x64": "0.21.5", - "@esbuild/netbsd-x64": "0.21.5", - "@esbuild/openbsd-x64": "0.21.5", - "@esbuild/sunos-x64": "0.21.5", - "@esbuild/win32-arm64": "0.21.5", - "@esbuild/win32-ia32": "0.21.5", - "@esbuild/win32-x64": "0.21.5" - } - }, - "node_modules/ethers": { - "version": "6.13.3", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/ethers-io/" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "license": "MIT", - "dependencies": { - "@adraffy/ens-normalize": "1.10.1", - "@noble/curves": "1.2.0", - "@noble/hashes": "1.3.2", - "@types/node": "18.15.13", - "aes-js": "4.0.0-beta.5", - "tslib": "2.4.0", - "ws": "8.17.1" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/follow-redirects": { - "version": "1.15.9", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", - "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - } - ], - "license": "MIT", - "engines": { - "node": ">=4.0" - }, - "peerDependenciesMeta": { - "debug": { - "optional": true - } - } - }, - "node_modules/js-sha3": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", - "integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==", - "license": "MIT" - }, - "node_modules/memorystream": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/memorystream/-/memorystream-0.3.1.tgz", - "integrity": "sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw==", - "engines": { - "node": ">= 0.10.0" - } - }, - "node_modules/nanoid": { - "version": "3.3.7", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "MIT", - "bin": { - "nanoid": "bin/nanoid.cjs" - }, - "engines": { - "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" - } - }, - "node_modules/os-tmpdir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/picocolors": { - "version": "1.1.0", - "dev": true, - "license": "ISC" - }, - "node_modules/postcss": { - "version": "8.4.47", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/postcss" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "MIT", - "dependencies": { - "nanoid": "^3.3.7", - "picocolors": "^1.1.0", - "source-map-js": "^1.2.1" - }, - "engines": { - "node": "^10 || ^12 || >=14" - } - }, - "node_modules/rollup": { - "version": "4.24.0", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/estree": "1.0.6" - }, - "bin": { - "rollup": "dist/bin/rollup" - }, - "engines": { - "node": ">=18.0.0", - "npm": ">=8.0.0" - }, - "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.24.0", - "@rollup/rollup-android-arm64": "4.24.0", - "@rollup/rollup-darwin-arm64": "4.24.0", - "@rollup/rollup-darwin-x64": "4.24.0", - "@rollup/rollup-linux-arm-gnueabihf": "4.24.0", - "@rollup/rollup-linux-arm-musleabihf": "4.24.0", - "@rollup/rollup-linux-arm64-gnu": "4.24.0", - "@rollup/rollup-linux-arm64-musl": "4.24.0", - "@rollup/rollup-linux-powerpc64le-gnu": "4.24.0", - "@rollup/rollup-linux-riscv64-gnu": "4.24.0", - "@rollup/rollup-linux-s390x-gnu": "4.24.0", - "@rollup/rollup-linux-x64-gnu": "4.24.0", - "@rollup/rollup-linux-x64-musl": "4.24.0", - "@rollup/rollup-win32-arm64-msvc": "4.24.0", - "@rollup/rollup-win32-ia32-msvc": "4.24.0", - "@rollup/rollup-win32-x64-msvc": "4.24.0", - "fsevents": "~2.3.2" - } - }, - "node_modules/semver": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", - "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", - "license": "ISC", - "bin": { - "semver": "bin/semver" - } - }, - "node_modules/solc": { - "version": "0.8.28", - "resolved": "https://registry.npmjs.org/solc/-/solc-0.8.28.tgz", - "integrity": "sha512-AFCiJ+b4RosyyNhnfdVH4ZR1+TxiL91iluPjw0EJslIu4LXGM9NYqi2z5y8TqochC4tcH9QsHfwWhOIC9jPDKA==", - "license": "MIT", - "dependencies": { - "command-exists": "^1.2.8", - "commander": "^8.1.0", - "follow-redirects": "^1.12.1", - "js-sha3": "0.8.0", - "memorystream": "^0.3.1", - "semver": "^5.5.0", - "tmp": "0.0.33" - }, - "bin": { - "solcjs": "solc.js" - }, - "engines": { - "node": ">=10.0.0" - } - }, - "node_modules/source-map-js": { - "version": "1.2.1", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/tmp": { - "version": "0.0.33", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", - "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", - "license": "MIT", - "dependencies": { - "os-tmpdir": "~1.0.2" - }, - "engines": { - "node": ">=0.6.0" - } - }, - "node_modules/tslib": { - "version": "2.4.0", - "license": "0BSD" - }, - "node_modules/typescript": { - "version": "5.6.3", - "dev": true, - "license": "Apache-2.0", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - }, - "node_modules/vite": { - "version": "5.4.8", - "dev": true, - "license": "MIT", - "dependencies": { - "esbuild": "^0.21.3", - "postcss": "^8.4.43", - "rollup": "^4.20.0" - }, - "bin": { - "vite": "bin/vite.js" - }, - "engines": { - "node": "^18.0.0 || >=20.0.0" - }, - "funding": { - "url": "https://github.com/vitejs/vite?sponsor=1" - }, - "optionalDependencies": { - "fsevents": "~2.3.3" - }, - "peerDependencies": { - "@types/node": "^18.0.0 || >=20.0.0", - "less": "*", - "lightningcss": "^1.21.0", - "sass": "*", - "sass-embedded": "*", - "stylus": "*", - "sugarss": "*", - "terser": "^5.4.0" - }, - "peerDependenciesMeta": { - "@types/node": { - "optional": true - }, - "less": { - "optional": true - }, - "lightningcss": { - "optional": true - }, - "sass": { - "optional": true - }, - "sass-embedded": { - "optional": true - }, - "stylus": { - "optional": true - }, - "sugarss": { - "optional": true - }, - "terser": { - "optional": true - } - } - }, - "node_modules/ws": { - "version": "8.17.1", - "license": "MIT", - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": ">=5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - } - } + "name": "demo", + "version": "0.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "demo", + "version": "0.0.0", + "dependencies": { + "ethers": "^6.13.1", + "solc": "^0.8.28" + }, + "devDependencies": { + "typescript": "^5.5.3", + "vite": "^5.4.8" + } + }, + "node_modules/@adraffy/ens-normalize": { + "version": "1.10.1", + "license": "MIT" + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.21.5", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@noble/curves": { + "version": "1.2.0", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.3.2" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/hashes": { + "version": "1.3.2", + "license": "MIT", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.24.0", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.24.0", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@types/estree": { + "version": "1.0.6", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "18.15.13", + "license": "MIT" + }, + "node_modules/aes-js": { + "version": "4.0.0-beta.5", + "license": "MIT" + }, + "node_modules/command-exists": { + "version": "1.2.9", + "resolved": "https://registry.npmjs.org/command-exists/-/command-exists-1.2.9.tgz", + "integrity": "sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w==", + "license": "MIT" + }, + "node_modules/commander": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", + "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==", + "license": "MIT", + "engines": { + "node": ">= 12" + } + }, + "node_modules/esbuild": { + "version": "0.21.5", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.21.5", + "@esbuild/android-arm": "0.21.5", + "@esbuild/android-arm64": "0.21.5", + "@esbuild/android-x64": "0.21.5", + "@esbuild/darwin-arm64": "0.21.5", + "@esbuild/darwin-x64": "0.21.5", + "@esbuild/freebsd-arm64": "0.21.5", + "@esbuild/freebsd-x64": "0.21.5", + "@esbuild/linux-arm": "0.21.5", + "@esbuild/linux-arm64": "0.21.5", + "@esbuild/linux-ia32": "0.21.5", + "@esbuild/linux-loong64": "0.21.5", + "@esbuild/linux-mips64el": "0.21.5", + "@esbuild/linux-ppc64": "0.21.5", + "@esbuild/linux-riscv64": "0.21.5", + "@esbuild/linux-s390x": "0.21.5", + "@esbuild/linux-x64": "0.21.5", + "@esbuild/netbsd-x64": "0.21.5", + "@esbuild/openbsd-x64": "0.21.5", + "@esbuild/sunos-x64": "0.21.5", + "@esbuild/win32-arm64": "0.21.5", + "@esbuild/win32-ia32": "0.21.5", + "@esbuild/win32-x64": "0.21.5" + } + }, + "node_modules/ethers": { + "version": "6.13.3", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/ethers-io/" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "dependencies": { + "@adraffy/ens-normalize": "1.10.1", + "@noble/curves": "1.2.0", + "@noble/hashes": "1.3.2", + "@types/node": "18.15.13", + "aes-js": "4.0.0-beta.5", + "tslib": "2.4.0", + "ws": "8.17.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/follow-redirects": { + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/js-sha3": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", + "integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==", + "license": "MIT" + }, + "node_modules/memorystream": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/memorystream/-/memorystream-0.3.1.tgz", + "integrity": "sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw==", + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/nanoid": { + "version": "3.3.7", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/picocolors": { + "version": "1.1.0", + "dev": true, + "license": "ISC" + }, + "node_modules/postcss": { + "version": "8.4.47", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.7", + "picocolors": "^1.1.0", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/rollup": { + "version": "4.24.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.6" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.24.0", + "@rollup/rollup-android-arm64": "4.24.0", + "@rollup/rollup-darwin-arm64": "4.24.0", + "@rollup/rollup-darwin-x64": "4.24.0", + "@rollup/rollup-linux-arm-gnueabihf": "4.24.0", + "@rollup/rollup-linux-arm-musleabihf": "4.24.0", + "@rollup/rollup-linux-arm64-gnu": "4.24.0", + "@rollup/rollup-linux-arm64-musl": "4.24.0", + "@rollup/rollup-linux-powerpc64le-gnu": "4.24.0", + "@rollup/rollup-linux-riscv64-gnu": "4.24.0", + "@rollup/rollup-linux-s390x-gnu": "4.24.0", + "@rollup/rollup-linux-x64-gnu": "4.24.0", + "@rollup/rollup-linux-x64-musl": "4.24.0", + "@rollup/rollup-win32-arm64-msvc": "4.24.0", + "@rollup/rollup-win32-ia32-msvc": "4.24.0", + "@rollup/rollup-win32-x64-msvc": "4.24.0", + "fsevents": "~2.3.2" + } + }, + "node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "license": "ISC", + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/solc": { + "version": "0.8.28", + "resolved": "https://registry.npmjs.org/solc/-/solc-0.8.28.tgz", + "integrity": "sha512-AFCiJ+b4RosyyNhnfdVH4ZR1+TxiL91iluPjw0EJslIu4LXGM9NYqi2z5y8TqochC4tcH9QsHfwWhOIC9jPDKA==", + "license": "MIT", + "dependencies": { + "command-exists": "^1.2.8", + "commander": "^8.1.0", + "follow-redirects": "^1.12.1", + "js-sha3": "0.8.0", + "memorystream": "^0.3.1", + "semver": "^5.5.0", + "tmp": "0.0.33" + }, + "bin": { + "solcjs": "solc.js" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "license": "MIT", + "dependencies": { + "os-tmpdir": "~1.0.2" + }, + "engines": { + "node": ">=0.6.0" + } + }, + "node_modules/tslib": { + "version": "2.4.0", + "license": "0BSD" + }, + "node_modules/typescript": { + "version": "5.6.3", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/vite": { + "version": "5.4.8", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.21.3", + "postcss": "^8.4.43", + "rollup": "^4.20.0" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^18.0.0 || >=20.0.0", + "less": "*", + "lightningcss": "^1.21.0", + "sass": "*", + "sass-embedded": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.4.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + } + } + }, + "node_modules/ws": { + "version": "8.17.1", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + } + } } diff --git a/substrate/frame/revive/rpc/examples/js/tsconfig.json b/substrate/frame/revive/rpc/examples/js/tsconfig.json index 0511b9f0e041..55cb8379e886 100644 --- a/substrate/frame/revive/rpc/examples/js/tsconfig.json +++ b/substrate/frame/revive/rpc/examples/js/tsconfig.json @@ -1,23 +1,23 @@ { - "compilerOptions": { - "target": "ES2020", - "useDefineForClassFields": true, - "module": "ESNext", - "lib": ["ES2020", "DOM", "DOM.Iterable"], - "skipLibCheck": true, + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "skipLibCheck": true, - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "isolatedModules": true, - "moduleDetection": "force", - "noEmit": true, + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "isolatedModules": true, + "moduleDetection": "force", + "noEmit": true, - /* Linting */ - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true - }, - "include": ["src"] + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"] } From 3a1b6890d9f9225698c4c32da0643a390c8683ae Mon Sep 17 00:00:00 2001 From: pgherveou Date: Wed, 13 Nov 2024 22:35:13 +0100 Subject: [PATCH 07/14] Add tests and address PR review --- .../rpc/examples/js/contracts/PiggyBank.sol | 4 ++ substrate/frame/revive/rpc/src/example.rs | 25 +++++++ substrate/frame/revive/rpc/src/tests.rs | 66 ++++++++++++++++--- substrate/frame/revive/src/lib.rs | 18 +---- 4 files changed, 90 insertions(+), 23 deletions(-) diff --git a/substrate/frame/revive/rpc/examples/js/contracts/PiggyBank.sol b/substrate/frame/revive/rpc/examples/js/contracts/PiggyBank.sol index 720decb531a8..1906c4658889 100644 --- a/substrate/frame/revive/rpc/examples/js/contracts/PiggyBank.sol +++ b/substrate/frame/revive/rpc/examples/js/contracts/PiggyBank.sol @@ -16,6 +16,10 @@ contract PiggyBank { return balance; } + function getDeposit() public view returns (uint) { + return balance; + } + function withdraw(uint withdrawAmount) public returns (uint remainingBal) { require(msg.sender == owner); balance -= withdrawAmount; diff --git a/substrate/frame/revive/rpc/src/example.rs b/substrate/frame/revive/rpc/src/example.rs index d2f9b509f4d2..0be18d7a4af8 100644 --- a/substrate/frame/revive/rpc/src/example.rs +++ b/substrate/frame/revive/rpc/src/example.rs @@ -105,6 +105,30 @@ impl TransactionBuilder { self } + /// Call eth_call to get the result of a view function + pub async fn eth_call( + self, + client: &(impl EthRpcClient + Send + Sync), + ) -> anyhow::Result> { + let TransactionBuilder { signer, value, input, to, .. } = self; + + let from = signer.address(); + let result = client + .call( + GenericTransaction { + from: Some(from), + input: Some(input.clone()), + value: Some(value), + to, + ..Default::default() + }, + None, + ) + .await + .with_context(|| "Failed to fetch gas estimate")?; + Ok(result.0) + } + /// Send the transaction. pub async fn send(self, client: &(impl EthRpcClient + Send + Sync)) -> anyhow::Result { let TransactionBuilder { signer, value, input, to, mutate } = self; @@ -156,6 +180,7 @@ impl TransactionBuilder { Ok(hash) } + /// Send the transaction and wait for the receipt. pub async fn send_and_wait_for_receipt( self, client: &(impl EthRpcClient + Send + Sync), diff --git a/substrate/frame/revive/rpc/src/tests.rs b/substrate/frame/revive/rpc/src/tests.rs index 3d2cbe42be8e..b9ec7700f520 100644 --- a/substrate/frame/revive/rpc/src/tests.rs +++ b/substrate/frame/revive/rpc/src/tests.rs @@ -22,6 +22,7 @@ use crate::{ EthRpcClient, }; use clap::Parser; +use ethabi::Token; use jsonrpsee::ws_client::{WsClient, WsClientBuilder}; use pallet_revive::{ create1, @@ -48,15 +49,12 @@ async fn ws_client_with_retry(url: &str) -> WsClient { } fn get_contract(name: &str) -> anyhow::Result<(Vec, ethabi::Contract)> { - const PVM_CONTRACTS: &str = include_str!("../examples/js/pvm-contracts.json"); - let pvm_contract: serde_json::Value = serde_json::from_str(PVM_CONTRACTS)?; - let pvm_contract = pvm_contract[name].as_object().unwrap(); - let bytecode = pvm_contract["bytecode"].as_str().unwrap(); - let bytecode = hex::decode(bytecode)?; + let pvm_dir: std::path::PathBuf = "./examples/js/pvm".into(); + let abi_dir: std::path::PathBuf = "./examples/js/abi".into(); + let bytecode = std::fs::read(pvm_dir.join(format!("{}.polkavm", name)))?; - let abi = pvm_contract["abi"].clone(); - let abi = serde_json::to_string(&abi)?; - let contract = ethabi::Contract::load(abi.as_bytes())?; + let abi = std::fs::read(abi_dir.join(format!("{}.json", name)))?; + let contract = ethabi::Contract::load(abi.as_slice())?; Ok((bytecode, contract)) } @@ -280,3 +278,55 @@ async fn invalid_transaction() -> anyhow::Result<()> { Ok(()) } + +#[tokio::test] +async fn native_evm_ratio_works() -> anyhow::Result<()> { + let _lock = SHARED_RESOURCES.write(); + let client = SharedResources::client().await; + let (bytecode, contract) = get_contract("piggyBank")?; + let contract_address = TransactionBuilder::default() + .input(bytecode) + .send_and_wait_for_receipt(&client) + .await? + .contract_address + .unwrap(); + + let value = 10_000_000_000_000_000_000u128; // 10 eth + TransactionBuilder::default() + .to(contract_address) + .input(contract.function("deposit")?.encode_input(&[])?.to_vec()) + .value(value.into()) + .send_and_wait_for_receipt(&client) + .await?; + + let get_deposit = contract.function("getDeposit")?; + let output = TransactionBuilder::default() + .to(contract_address) + .input(get_deposit.encode_input(&[])?.to_vec()) + .eth_call(&client) + .await?; + let output = get_deposit.decode_output(&output)?; + assert_eq!(output[0], Token::Uint(value.into())); + + let withdraw_value = 1_000_000_000_000_000_000u128; // 1 eth + TransactionBuilder::default() + .to(contract_address) + .input( + contract + .function("withdraw")? + .encode_input(&[Token::Uint(withdraw_value.into())])? + .to_vec(), + ) + .send_and_wait_for_receipt(&client) + .await?; + + let output = TransactionBuilder::default() + .to(contract_address) + .input(get_deposit.encode_input(&[])?.to_vec()) + .eth_call(&client) + .await?; + let output = get_deposit.decode_output(&output)?; + assert_eq!(output[0], Token::Uint((value - withdraw_value).into())); + + Ok(()) +} diff --git a/substrate/frame/revive/src/lib.rs b/substrate/frame/revive/src/lib.rs index a1fd43841fea..d4c2709a32c3 100644 --- a/substrate/frame/revive/src/lib.rs +++ b/substrate/frame/revive/src/lib.rs @@ -47,7 +47,7 @@ use crate::{ storage::{meter::Meter as StorageMeter, ContractInfo, DeletionQueueManager}, wasm::{CodeInfo, RuntimeCosts, WasmBlob}, }; -use alloc::{boxed::Box, string::String}; +use alloc::boxed::Box; use codec::{Codec, Decode, Encode}; use environmental::*; use frame_support::{ @@ -1268,12 +1268,6 @@ where collect_events, ); - log::debug!(target: LOG_TARGET, "Result: {}, Revert: {}, Debug message: {:?}", - result.result.is_ok(), - result.result.as_ref().map_or(false, |v| v.did_revert()), - String::from_utf8(result.debug_message) - ); - let result = EthContractResult { gas_required: result.gas_required, storage_deposit: result.storage_deposit.charge_or_zero(), @@ -1319,12 +1313,6 @@ where collect_events, ); - log::debug!(target: LOG_TARGET, "Result: {}, Revert: {}, Debug message: {:?}", - result.result.is_ok(), - result.result.as_ref().map_or(false, |v| v.result.did_revert()), - String::from_utf8(result.debug_message) - ); - let result = EthContractResult { gas_required: result.gas_required, storage_deposit: result.storage_deposit.charge_or_zero(), @@ -1441,12 +1429,12 @@ where } /// Convert a native balance to EVM balance. - pub fn convert_native_to_evm(value: BalanceOf) -> U256 { + fn convert_native_to_evm(value: BalanceOf) -> U256 { value.into().saturating_mul(T::NativeToEthRatio::get().into()) } /// Convert an EVM balance to a native balance. - pub fn convert_evm_to_native(value: U256) -> Result, Error> { + fn convert_evm_to_native(value: U256) -> Result, Error> { if value.is_zero() { return Ok(Zero::zero()) } From d4364fda0e7d159b9b0fab677328cd7d26e292bd Mon Sep 17 00:00:00 2001 From: pgherveou Date: Wed, 13 Nov 2024 22:42:56 +0100 Subject: [PATCH 08/14] Use convert_fns --- substrate/frame/revive/src/evm/runtime.rs | 7 ++++--- substrate/frame/revive/src/lib.rs | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/substrate/frame/revive/src/evm/runtime.rs b/substrate/frame/revive/src/evm/runtime.rs index bfff5e79e3ae..d366999b81ca 100644 --- a/substrate/frame/revive/src/evm/runtime.rs +++ b/substrate/frame/revive/src/evm/runtime.rs @@ -313,9 +313,10 @@ pub trait EthExtra { return Err(InvalidTransaction::Call); } - let value = (value / U256::from(::NativeToEthRatio::get())) - .try_into() - .map_err(|_| InvalidTransaction::Call)?; + let value = crate::Pallet::::convert_evm_to_native(value).map_err(|err| { + log::debug!(target: LOG_TARGET, "Failed to convert value to native: {err:?}"); + InvalidTransaction::Call + })?; let call = if let Some(dest) = to { crate::Call::call:: { diff --git a/substrate/frame/revive/src/lib.rs b/substrate/frame/revive/src/lib.rs index d4c2709a32c3..c6a2d36c8662 100644 --- a/substrate/frame/revive/src/lib.rs +++ b/substrate/frame/revive/src/lib.rs @@ -1336,7 +1336,7 @@ where }; let mut tx = TransactionLegacyUnsigned { - value: value.into().saturating_mul(T::NativeToEthRatio::get().into()), + value: Self::convert_native_to_evm(value), input: input.into(), nonce: nonce.into(), chain_id: Some(T::ChainId::get().into()), From d30a4b02dd6b71cff2150b1f0f00d1da51b1b9d4 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Wed, 13 Nov 2024 22:50:54 +0100 Subject: [PATCH 09/14] simplify test --- substrate/frame/revive/rpc/src/example.rs | 2 +- substrate/frame/revive/rpc/src/tests.rs | 19 ++++--------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/substrate/frame/revive/rpc/src/example.rs b/substrate/frame/revive/rpc/src/example.rs index 0be18d7a4af8..20f00465b146 100644 --- a/substrate/frame/revive/rpc/src/example.rs +++ b/substrate/frame/revive/rpc/src/example.rs @@ -125,7 +125,7 @@ impl TransactionBuilder { None, ) .await - .with_context(|| "Failed to fetch gas estimate")?; + .with_context(|| "eth_call failed")?; Ok(result.0) } diff --git a/substrate/frame/revive/rpc/src/tests.rs b/substrate/frame/revive/rpc/src/tests.rs index b9ec7700f520..9797e2652658 100644 --- a/substrate/frame/revive/rpc/src/tests.rs +++ b/substrate/frame/revive/rpc/src/tests.rs @@ -299,14 +299,8 @@ async fn native_evm_ratio_works() -> anyhow::Result<()> { .send_and_wait_for_receipt(&client) .await?; - let get_deposit = contract.function("getDeposit")?; - let output = TransactionBuilder::default() - .to(contract_address) - .input(get_deposit.encode_input(&[])?.to_vec()) - .eth_call(&client) - .await?; - let output = get_deposit.decode_output(&output)?; - assert_eq!(output[0], Token::Uint(value.into())); + let contract_value = client.get_balance(ethan.address(), BlockTag::Latest.into()).await?; + assert_eq!(contract_value, value.into()); let withdraw_value = 1_000_000_000_000_000_000u128; // 1 eth TransactionBuilder::default() @@ -320,13 +314,8 @@ async fn native_evm_ratio_works() -> anyhow::Result<()> { .send_and_wait_for_receipt(&client) .await?; - let output = TransactionBuilder::default() - .to(contract_address) - .input(get_deposit.encode_input(&[])?.to_vec()) - .eth_call(&client) - .await?; - let output = get_deposit.decode_output(&output)?; - assert_eq!(output[0], Token::Uint((value - withdraw_value).into())); + let contract_value = client.get_balance(ethan.address(), BlockTag::Latest.into()).await?; + assert_eq!(contract_value, (value - withdraw_value).into()); Ok(()) } From 96d0f87c0c73abe0c6735746b3cccbe13fa6b49e Mon Sep 17 00:00:00 2001 From: pgherveou Date: Wed, 13 Nov 2024 23:05:00 +0100 Subject: [PATCH 10/14] fix test builds --- substrate/frame/revive/rpc/src/tests.rs | 4 ++-- substrate/frame/revive/src/exec.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/substrate/frame/revive/rpc/src/tests.rs b/substrate/frame/revive/rpc/src/tests.rs index 9797e2652658..eb23bd7583a0 100644 --- a/substrate/frame/revive/rpc/src/tests.rs +++ b/substrate/frame/revive/rpc/src/tests.rs @@ -299,7 +299,7 @@ async fn native_evm_ratio_works() -> anyhow::Result<()> { .send_and_wait_for_receipt(&client) .await?; - let contract_value = client.get_balance(ethan.address(), BlockTag::Latest.into()).await?; + let contract_value = client.get_balance(contract_address, BlockTag::Latest.into()).await?; assert_eq!(contract_value, value.into()); let withdraw_value = 1_000_000_000_000_000_000u128; // 1 eth @@ -314,7 +314,7 @@ async fn native_evm_ratio_works() -> anyhow::Result<()> { .send_and_wait_for_receipt(&client) .await?; - let contract_value = client.get_balance(ethan.address(), BlockTag::Latest.into()).await?; + let contract_value = client.get_balance(contract_address, BlockTag::Latest.into()).await?; assert_eq!(contract_value, (value - withdraw_value).into()); Ok(()) diff --git a/substrate/frame/revive/src/exec.rs b/substrate/frame/revive/src/exec.rs index 46fd2292062e..30aeedbf3a63 100644 --- a/substrate/frame/revive/src/exec.rs +++ b/substrate/frame/revive/src/exec.rs @@ -834,7 +834,7 @@ where origin, gas_meter, storage_meter, - value, + value.into(), debug_message, ) .unwrap() @@ -843,7 +843,7 @@ where /// Create a new call stack. /// - /// Returns `None` when calling a non existant contract. This is not an error case + /// Returns `None` when calling a non existent contract. This is not an error case /// since this will result in a value transfer. fn new( args: FrameArgs, From 82da728931cad43de82b8830aea754ba2680dc5b Mon Sep 17 00:00:00 2001 From: pgherveou Date: Wed, 13 Nov 2024 23:08:04 +0100 Subject: [PATCH 11/14] fix --all-features --- substrate/frame/revive/src/exec.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/substrate/frame/revive/src/exec.rs b/substrate/frame/revive/src/exec.rs index 30aeedbf3a63..fdb45f045bbc 100644 --- a/substrate/frame/revive/src/exec.rs +++ b/substrate/frame/revive/src/exec.rs @@ -2091,7 +2091,7 @@ mod tests { set_balance(&BOB, 0); let origin = Origin::from_account_id(ALICE); - MockStack::transfer(&origin, &ALICE, &BOB, 55).unwrap(); + MockStack::transfer(&origin, &ALICE, &BOB, 55u64.into()).unwrap(); let min_balance = ::Currency::minimum_balance(); assert_eq!(get_balance(&ALICE), 45 - min_balance); @@ -2112,7 +2112,12 @@ mod tests { set_balance(&ALICE, ed * 2); set_balance(&BOB, ed + value); - assert_ok!(MockStack::transfer(&Origin::from_account_id(ALICE), &BOB, &CHARLIE, value)); + assert_ok!(MockStack::transfer( + &Origin::from_account_id(ALICE), + &BOB, + &CHARLIE, + value.into() + )); assert_eq!(get_balance(&ALICE), ed); assert_eq!(get_balance(&BOB), ed); assert_eq!(get_balance(&CHARLIE), ed + value); @@ -2121,7 +2126,7 @@ mod tests { set_balance(&ALICE, ed); set_balance(&BOB, ed + value); assert_err!( - MockStack::transfer(&Origin::from_account_id(ALICE), &BOB, &DJANGO, value), + MockStack::transfer(&Origin::from_account_id(ALICE), &BOB, &DJANGO, value.into()), >::TransferFailed ); @@ -2129,7 +2134,7 @@ mod tests { set_balance(&ALICE, ed * 2); set_balance(&BOB, value); assert_err!( - MockStack::transfer(&Origin::from_account_id(ALICE), &BOB, &EVE, value), + MockStack::transfer(&Origin::from_account_id(ALICE), &BOB, &EVE, value.into()), >::TransferFailed ); // The ED transfer would work. But it should only be executed with the actual transfer @@ -2251,7 +2256,7 @@ mod tests { ExtBuilder::default().build().execute_with(|| { set_balance(&from, 0); - let result = MockStack::transfer(&origin, &from, &dest, 100); + let result = MockStack::transfer(&origin, &from, &dest, 100u64.into()); assert_eq!(result, Err(Error::::TransferFailed.into())); assert_eq!(get_balance(&from), 0); From 0604cbc2a326082b66c087f27d0445d89dd132de Mon Sep 17 00:00:00 2001 From: pgherveou Date: Wed, 13 Nov 2024 23:56:03 +0100 Subject: [PATCH 12/14] fix benchmarks --- substrate/frame/revive/src/benchmarking/mod.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/substrate/frame/revive/src/benchmarking/mod.rs b/substrate/frame/revive/src/benchmarking/mod.rs index 593c16cbb2d8..40ad3a3aed17 100644 --- a/substrate/frame/revive/src/benchmarking/mod.rs +++ b/substrate/frame/revive/src/benchmarking/mod.rs @@ -1516,7 +1516,7 @@ mod benchmarks { let callee_bytes = callee.encode(); let callee_len = callee_bytes.len() as u32; - let value: BalanceOf = t.into(); + let value: BalanceOf = (1_000_000 * t).into(); let value_bytes = Into::::into(value).encode(); let deposit: BalanceOf = (u32::MAX - 100).into(); @@ -1591,7 +1591,7 @@ mod benchmarks { let hash_bytes = hash.encode(); let hash_len = hash_bytes.len() as u32; - let value: BalanceOf = 1u32.into(); + let value: BalanceOf = 1_000_000u32.into(); let value_bytes = Into::::into(value).encode(); let value_len = value_bytes.len() as u32; @@ -1645,7 +1645,10 @@ mod benchmarks { assert_ok!(result); assert!(ContractInfoOf::::get(&addr).is_some()); - assert_eq!(T::Currency::balance(&account_id), Pallet::::min_balance() + value); + assert_eq!( + T::Currency::balance(&account_id), + Pallet::::min_balance() + Pallet::::convert_evm_to_native(value.into()).unwrap() + ); Ok(()) } From 0bd3f7448d0e3a076ae5dd415b7aa402eb8add6a Mon Sep 17 00:00:00 2001 From: pgherveou Date: Thu, 14 Nov 2024 10:23:28 +0100 Subject: [PATCH 13/14] Get rid of the convert ratio on the rpc --- .../assets/asset-hub-westend/src/lib.rs | 17 +++----- substrate/bin/node/runtime/src/lib.rs | 11 +++-- .../frame/revive/rpc/revive_chain.metadata | Bin 656635 -> 658056 bytes substrate/frame/revive/rpc/src/client.rs | 38 ++++------------- .../frame/revive/rpc/src/subxt_client.rs | 5 +++ substrate/frame/revive/src/lib.rs | 39 +++++++++++++----- 6 files changed, 53 insertions(+), 57 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index e66c4f27fbe8..2206aea78ec2 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -45,10 +45,7 @@ use frame_support::{ ord_parameter_types, parameter_types, traits::{ fungible, fungibles, - tokens::{ - imbalance::ResolveAssetTo, nonfungibles_v2::Inspect, Fortitude::Polite, - Preservation::Expendable, - }, + tokens::{imbalance::ResolveAssetTo, nonfungibles_v2::Inspect}, AsEnsureOriginWithArg, ConstBool, ConstU128, ConstU32, ConstU64, ConstU8, InstanceFilter, Nothing, TransformOrigin, }, @@ -68,7 +65,7 @@ use parachains_common::{ NORMAL_DISPATCH_RATIO, }; use sp_api::impl_runtime_apis; -use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H160}; +use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H160, U256}; use sp_runtime::{ generic, impl_opaque_keys, traits::{AccountIdConversion, BlakeTwo256, Block as BlockT, Saturating, Verify}, @@ -127,7 +124,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: alloc::borrow::Cow::Borrowed("westmint"), impl_name: alloc::borrow::Cow::Borrowed("westmint"), authoring_version: 1, - spec_version: 1_016_005, + spec_version: 1_016_006, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 16, @@ -2080,10 +2077,8 @@ impl_runtime_apis! { impl pallet_revive::ReviveApi for Runtime { - fn balance(address: H160) -> Balance { - use frame_support::traits::fungible::Inspect; - let account = ::AddressMapper::to_account_id(&address); - Balances::reducible_balance(&account, Expendable, Polite) + fn balance(address: H160) -> U256 { + Revive::evm_balance(&address) } fn nonce(address: H160) -> Nonce { @@ -2093,7 +2088,7 @@ impl_runtime_apis! { fn eth_transact( from: H160, dest: Option, - value: Balance, + value: U256, input: Vec, gas_limit: Option, storage_deposit_limit: Option, diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index 5a2ff3ceb7f6..914b51fb5621 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -54,7 +54,7 @@ use frame_support::{ }, tokens::{ imbalance::ResolveAssetTo, nonfungibles_v2::Inspect, pay::PayAssetFromAccount, - Fortitude::Polite, GetSalary, PayFromAccount, Preservation::Preserve, + GetSalary, PayFromAccount, }, AsEnsureOriginWithArg, ConstBool, ConstU128, ConstU16, ConstU32, ConstU64, Contains, Currency, EitherOfDiverse, EnsureOriginWithArg, EqualPrivilegeOnly, Imbalance, InsideBoth, @@ -86,6 +86,7 @@ use pallet_nis::WithMaximumOf; use pallet_nomination_pools::PoolId; use pallet_revive::{evm::runtime::EthExtra, AddressMapper}; use pallet_session::historical as pallet_session_historical; +use sp_core::U256; // Can't use `FungibleAdapter` here until Treasury pallet migrates to fungibles // use pallet_broker::TaskId; @@ -3205,10 +3206,8 @@ impl_runtime_apis! { impl pallet_revive::ReviveApi for Runtime { - fn balance(address: H160) -> Balance { - use frame_support::traits::fungible::Inspect; - let account = ::AddressMapper::to_account_id(&address); - Balances::reducible_balance(&account, Preserve, Polite) + fn balance(address: H160) -> U256 { + Revive::evm_balance(&address) } fn nonce(address: H160) -> Nonce { @@ -3219,7 +3218,7 @@ impl_runtime_apis! { fn eth_transact( from: H160, dest: Option, - value: Balance, + value: U256, input: Vec, gas_limit: Option, storage_deposit_limit: Option, diff --git a/substrate/frame/revive/rpc/revive_chain.metadata b/substrate/frame/revive/rpc/revive_chain.metadata index e5bfa0820b100bce59107541915f9352fce1c99a..3560b3b90407acce7f602ce91ac089843be8dea8 100644 GIT binary patch delta 20100 zcmb_^3tUvy_W#*u&YTC#FoOc})ImidfxsuIsHmuzsHpfx9bwc-V0fyOXqI-RG9MEz zDM`6E@6BIQ8JA90mQ>!*!bfRpX=-U@<*V}Eyk-5r=gg=>^!t4Npa192htKSN_FjAK zwbx#It+m(Q=loI~yS64)EOeCHE$eoR9Yl809VYf*r`^NEd)YP0{!R*UpA+LKX#@*r zKiz&F$bP2ZzLPq;Q>7lv=$Jmqgl zWLEc?)RdLXT5MnFurljJBpkCAIhK{Tu%rpaaZf!qR{y`TWK3mqQ# zyaKzk(2<`w(mixw68q3yJn$qt)|feH40C_h+8qTO2Pd*4?tOzJr6U|CzQ-MNe>r#( zJ4wGcu}IxJ?0a{=k;B{{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V&ty}`9F0W_ycJY|6q+vF$J z*njiKDLw(fv$24V>w9l=&2c^ZHurnvlI4k{F^lZ;mP}h}pEuok$ifi49WKpYV#BZdY!ht7i@d$cNhEo|s@=|*y16bsgk;#Z4~UH*$aY_8s02?S!Qf?ZF|q*2oVVLcC((-FNv>L$X&GJo6r3 z>=Ec?)dorS$^hwo-sYR-C6_!H;?-xa_NnR|40bFUoUI!7^D&~A%`3cEd$^;K*~IK{ z-vRz#!qrh9@(+li(5n>RQ}SRDdK~0~4BohAe|*lzsap>6XC)G@4r%7uRQ>fc{%?XZ z^ZE(?h*aSveF%l0^Lt?G=h}Y_1bLtHXVA03elZ3^l@nosNb1$vulX8+4s-u+_->T3 z)8FtNUOSwG$6JeSxh3&C;jQoZy>Rw4PZsxjLCZP50$wG~{%25mu$pUMem#?mI0r-La($bQ6m~$Gn_!?xM;}45BbmWhbTN>W` z2)urQ_m)GvOu6=as}a7szyt4;xO(#fe?r9VqVf_yk8bFa@A*T>uM6KJ4^XXO%MW~# zmR|gUPs7QLXycFTY;0=di^YHl>j?axJ?7{S^)RkgP_O`5>=l{_2itg*T6~pn5p`(q zpZF5djoX=s_$04_7k=eG8k(`8`Zr#O2lS!sdq}k4BF<22|WB++zqalv{=W4;^Q&YXATM diff --git a/substrate/frame/revive/rpc/src/client.rs b/substrate/frame/revive/rpc/src/client.rs index bc4f59b5e26e..15a30816304a 100644 --- a/substrate/frame/revive/rpc/src/client.rs +++ b/substrate/frame/revive/rpc/src/client.rs @@ -236,7 +236,6 @@ struct ClientInner { cache: Shared>, chain_id: u64, max_block_weight: Weight, - native_to_evm_ratio: U256, } impl ClientInner { @@ -252,20 +251,10 @@ impl ClientInner { let rpc = LegacyRpcMethods::::new(RpcClient::new(rpc_client.clone())); - let (native_to_evm_ratio, chain_id, max_block_weight) = - tokio::try_join!(native_to_evm_ratio(&api), chain_id(&api), max_block_weight(&api))?; + let (chain_id, max_block_weight) = + tokio::try_join!(chain_id(&api), max_block_weight(&api))?; - Ok(Self { api, rpc_client, rpc, cache, chain_id, max_block_weight, native_to_evm_ratio }) - } - - /// Convert a native balance to an EVM balance. - fn native_to_evm_decimals(&self, value: U256) -> U256 { - value.saturating_mul(self.native_to_evm_ratio) - } - - /// Convert an evm balance to a native balance. - fn evm_to_native_decimals(&self, value: U256) -> U256 { - value / self.native_to_evm_ratio + Ok(Self { api, rpc_client, rpc, cache, chain_id, max_block_weight }) } /// Get the receipt infos from the extrinsics in a block. @@ -368,13 +357,6 @@ async fn max_block_weight(api: &OnlineClient) -> Result) -> Result { - let query = subxt_client::constants().revive().native_to_eth_ratio(); - let ratio = api.constants().at(&query)?; - Ok(U256::from(ratio)) -} - /// Extract the block timestamp. async fn extract_block_timestamp(block: &SubstrateBlock) -> Option { let extrinsics = block.extrinsics().await.ok()?; @@ -607,8 +589,9 @@ impl Client { let runtime_api = self.runtime_api(at).await?; let payload = subxt_client::apis().revive_api().balance(address); - let balance = runtime_api.call(payload).await?.into(); - Ok(self.inner.native_to_evm_decimals(balance)) + let balance = runtime_api.call(payload).await?; + + Ok(*balance) } /// Get the contract storage for the given contract address and key. @@ -659,20 +642,15 @@ impl Client { ) -> Result>, ClientError> { let runtime_api = self.runtime_api(&block).await?; - let value = self - .inner - .evm_to_native_decimals(tx.value.unwrap_or_default()) - .try_into() - .map_err(|_| ClientError::ConversionFailed)?; - // TODO: remove once subxt is updated + let value = tx.value.unwrap_or_default(); let from = tx.from.map(|v| v.0.into()); let to = tx.to.map(|v| v.0.into()); let payload = subxt_client::apis().revive_api().eth_transact( from.unwrap_or_default(), to, - value, + subxt::utils::Static(value), tx.input.clone().unwrap_or_default().0, None, None, diff --git a/substrate/frame/revive/rpc/src/subxt_client.rs b/substrate/frame/revive/rpc/src/subxt_client.rs index 11a0d51ed03e..a232b231bc7c 100644 --- a/substrate/frame/revive/rpc/src/subxt_client.rs +++ b/substrate/frame/revive/rpc/src/subxt_client.rs @@ -21,6 +21,11 @@ use subxt::config::{signed_extensions, Config, PolkadotConfig}; #[subxt::subxt( runtime_metadata_path = "revive_chain.metadata", + // TODO remove once subxt use the same U256 type + substitute_type( + path = "primitive_types::U256", + with = "::subxt::utils::Static<::sp_core::U256>" + ), substitute_type( path = "pallet_revive::primitives::EthContractResult", with = "::subxt::utils::Static<::pallet_revive::EthContractResult>" diff --git a/substrate/frame/revive/src/lib.rs b/substrate/frame/revive/src/lib.rs index c6a2d36c8662..caecf07c4071 100644 --- a/substrate/frame/revive/src/lib.rs +++ b/substrate/frame/revive/src/lib.rs @@ -59,6 +59,7 @@ use frame_support::{ pallet_prelude::DispatchClass, traits::{ fungible::{Inspect, Mutate, MutateHold}, + tokens::{Fortitude::Polite, Preservation::Preserve}, ConstU32, ConstU64, Contains, EnsureOrigin, Get, IsType, OriginTrait, Time, }, weights::{Weight, WeightMeter}, @@ -1216,7 +1217,7 @@ where /// /// - `origin`: The origin of the call. /// - `dest`: The destination address of the call. - /// - `value`: The value to transfer. + /// - `value`: The EVM value to transfer. /// - `input`: The input data. /// - `gas_limit`: The gas limit enforced during contract execution. /// - `storage_deposit_limit`: The maximum balance that can be charged to the caller for storage @@ -1228,7 +1229,7 @@ where pub fn bare_eth_transact( origin: T::AccountId, dest: Option, - value: BalanceOf, + value: U256, input: Vec, gas_limit: Weight, storage_deposit_limit: BalanceOf, @@ -1252,6 +1253,18 @@ where // Get the nonce to encode in the tx. let nonce: T::Nonce = >::account_nonce(&origin); + // Convert the value to the native balance type. + let native_value = match Self::convert_evm_to_native(value) { + Ok(v) => v, + Err(err) => + return EthContractResult { + gas_required: Default::default(), + storage_deposit: Default::default(), + fee: Default::default(), + result: Err(err.into()), + }, + }; + // Dry run the call let (mut result, dispatch_info) = match dest { // A contract call. @@ -1260,7 +1273,7 @@ where let result = crate::Pallet::::bare_call( T::RuntimeOrigin::signed(origin), dest, - value, + native_value, gas_limit, storage_deposit_limit, input.clone(), @@ -1277,7 +1290,7 @@ where // Get the dispatch info of the call. let dispatch_call: ::RuntimeCall = crate::Call::::call { dest, - value, + value: native_value, gas_limit: result.gas_required, storage_deposit_limit: result.storage_deposit, data: input.clone(), @@ -1303,7 +1316,7 @@ where // Dry run the call. let result = crate::Pallet::::bare_instantiate( T::RuntimeOrigin::signed(origin), - value, + native_value, gas_limit, storage_deposit_limit, Code::Upload(code.to_vec()), @@ -1323,7 +1336,7 @@ where // Get the dispatch info of the call. let dispatch_call: ::RuntimeCall = crate::Call::::instantiate_with_code { - value, + value: native_value, gas_limit: result.gas_required, storage_deposit_limit: result.storage_deposit, code: code.to_vec(), @@ -1336,7 +1349,7 @@ where }; let mut tx = TransactionLegacyUnsigned { - value: Self::convert_native_to_evm(value), + value, input: input.into(), nonce: nonce.into(), chain_id: Some(T::ChainId::get().into()), @@ -1375,6 +1388,12 @@ where result } + /// Get the balance with EVM decimals of the given `address`. + pub fn evm_balance(address: &H160) -> U256 { + let account = T::AddressMapper::to_account_id(&address); + Self::convert_native_to_evm(T::Currency::reducible_balance(&account, Preserve, Polite)) + } + /// A generalized version of [`Self::upload_code`]. /// /// It is identical to [`Self::upload_code`] and only differs in the information it returns. @@ -1473,8 +1492,8 @@ sp_api::decl_runtime_apis! { BlockNumber: Codec, EventRecord: Codec, { - /// Returns the free balance of the given `[H160]` address. - fn balance(address: H160) -> Balance; + /// Returns the free balance of the given `[H160]` address, using EVM decimals. + fn balance(address: H160) -> U256; /// Returns the nonce of the given `[H160]` address. fn nonce(address: H160) -> Nonce; @@ -1511,7 +1530,7 @@ sp_api::decl_runtime_apis! { fn eth_transact( origin: H160, dest: Option, - value: Balance, + value: U256, input: Vec, gas_limit: Option, storage_deposit_limit: Option, From 4854c10323f21e331e258ac6970f755be4c0d62b Mon Sep 17 00:00:00 2001 From: pgherveou Date: Thu, 14 Nov 2024 10:25:54 +0100 Subject: [PATCH 14/14] nit --- substrate/frame/revive/rpc/src/client.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/substrate/frame/revive/rpc/src/client.rs b/substrate/frame/revive/rpc/src/client.rs index 15a30816304a..4606a40269be 100644 --- a/substrate/frame/revive/rpc/src/client.rs +++ b/substrate/frame/revive/rpc/src/client.rs @@ -643,14 +643,14 @@ impl Client { let runtime_api = self.runtime_api(&block).await?; // TODO: remove once subxt is updated - let value = tx.value.unwrap_or_default(); + let value = subxt::utils::Static(tx.value.unwrap_or_default()); let from = tx.from.map(|v| v.0.into()); let to = tx.to.map(|v| v.0.into()); let payload = subxt_client::apis().revive_api().eth_transact( from.unwrap_or_default(), to, - subxt::utils::Static(value), + value, tx.input.clone().unwrap_or_default().0, None, None,