Skip to content

Commit

Permalink
evm/client/wasm/query unit tests (sei-protocol#1574)
Browse files Browse the repository at this point in the history
* check to see if any tests touch these funcs

fix

test not working

getting write protection error on TestHandleERC20TokenInfo

write protection err

some cleanup

very simplified contract

add executable

executable works

executable works with complex erc20

refactor deploy contract out

token info done

finished rest of functions

cleanups

* remove comments in ERC20 and ERC721

* cleanup

* fix
  • Loading branch information
jewei1997 authored Apr 30, 2024
1 parent dd2e61d commit 954bd21
Show file tree
Hide file tree
Showing 12 changed files with 1,075 additions and 19 deletions.
1 change: 1 addition & 0 deletions example/contracts/erc20/ERC20.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]
1 change: 1 addition & 0 deletions example/contracts/erc20/ERC20.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
60806040526040518060400160405280600581526020017f45524332300000000000000000000000000000000000000000000000000000008152505f908162000049919062000323565b506040518060400160405280600581526020017f45524332300000000000000000000000000000000000000000000000000000008152506001908162000090919062000323565b50601260025f6101000a81548160ff021916908360ff160217905550348015620000b8575f80fd5b5062000407565b5f81519050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f60028204905060018216806200013b57607f821691505b602082108103620001515762000150620000f6565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f60088302620001b57fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8262000178565b620001c1868362000178565b95508019841693508086168417925050509392505050565b5f819050919050565b5f819050919050565b5f6200020b62000205620001ff84620001d9565b620001e2565b620001d9565b9050919050565b5f819050919050565b6200022683620001eb565b6200023e620002358262000212565b84845462000184565b825550505050565b5f90565b6200025462000246565b620002618184846200021b565b505050565b5b8181101562000288576200027c5f826200024a565b60018101905062000267565b5050565b601f821115620002d757620002a18162000157565b620002ac8462000169565b81016020851015620002bc578190505b620002d4620002cb8562000169565b83018262000266565b50505b505050565b5f82821c905092915050565b5f620002f95f1984600802620002dc565b1980831691505092915050565b5f620003138383620002e8565b9150826002028217905092915050565b6200032e82620000bf565b67ffffffffffffffff8111156200034a5762000349620000c9565b5b62000356825462000123565b620003638282856200028c565b5f60209050601f83116001811462000399575f841562000384578287015190505b62000390858262000306565b865550620003ff565b601f198416620003a98662000157565b5f5b82811015620003d257848901518255600182019150602085019450602081019050620003ab565b86831015620003f25784890151620003ee601f891682620002e8565b8355505b6001600288020188555050505b505050505050565b610dd280620004155f395ff3fe608060405234801561000f575f80fd5b5060043610610091575f3560e01c8063313ce56711610064578063313ce5671461013157806370a082311461014f57806395d89b411461017f578063a9059cbb1461019d578063dd62ed3e146101cd57610091565b806306fdde0314610095578063095ea7b3146100b357806318160ddd146100e357806323b872dd14610101575b5f80fd5b61009d6101fd565b6040516100aa9190610959565b60405180910390f35b6100cd60048036038101906100c89190610a0a565b610288565b6040516100da9190610a62565b60405180910390f35b6100eb610375565b6040516100f89190610a8a565b60405180910390f35b61011b60048036038101906101169190610aa3565b610386565b6040516101289190610a62565b60405180910390f35b610139610666565b6040516101469190610b0e565b60405180910390f35b61016960048036038101906101649190610b27565b610678565b6040516101769190610a8a565b60405180910390f35b61018761068d565b6040516101949190610959565b60405180910390f35b6101b760048036038101906101b29190610a0a565b610719565b6040516101c49190610a62565b60405180910390f35b6101e760048036038101906101e29190610b52565b6108af565b6040516101f49190610a8a565b60405180910390f35b5f805461020990610bbd565b80601f016020809104026020016040519081016040528092919081815260200182805461023590610bbd565b80156102805780601f1061025757610100808354040283529160200191610280565b820191905f5260205f20905b81548152906001019060200180831161026357829003601f168201915b505050505081565b5f8160045f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040516103639190610a8a565b60405180910390a36001905092915050565b5f69d3c21bcecceda1000000905090565b5f8160035f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20541015610407576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103fe90610c5d565b60405180910390fd5b8160045f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205410156104c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104b990610ceb565b60405180910390fd5b8160035f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825461050e9190610d36565b925050819055508160035f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8282546105619190610d69565b925050819055508160045f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8282546105ef9190610d36565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516106539190610a8a565b60405180910390a3600190509392505050565b60025f9054906101000a900460ff1681565b6003602052805f5260405f205f915090505481565b6001805461069a90610bbd565b80601f01602080910402602001604051908101604052809291908181526020018280546106c690610bbd565b80156107115780601f106106e857610100808354040283529160200191610711565b820191905f5260205f20905b8154815290600101906020018083116106f457829003601f168201915b505050505081565b5f8160035f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054101561079a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161079190610c5d565b60405180910390fd5b8160035f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8282546107e69190610d36565b925050819055508160035f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8282546108399190610d69565b925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161089d9190610a8a565b60405180910390a36001905092915050565b6004602052815f5260405f20602052805f5260405f205f91509150505481565b5f81519050919050565b5f82825260208201905092915050565b5f5b838110156109065780820151818401526020810190506108eb565b5f8484015250505050565b5f601f19601f8301169050919050565b5f61092b826108cf565b61093581856108d9565b93506109458185602086016108e9565b61094e81610911565b840191505092915050565b5f6020820190508181035f8301526109718184610921565b905092915050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6109a68261097d565b9050919050565b6109b68161099c565b81146109c0575f80fd5b50565b5f813590506109d1816109ad565b92915050565b5f819050919050565b6109e9816109d7565b81146109f3575f80fd5b50565b5f81359050610a04816109e0565b92915050565b5f8060408385031215610a2057610a1f610979565b5b5f610a2d858286016109c3565b9250506020610a3e858286016109f6565b9150509250929050565b5f8115159050919050565b610a5c81610a48565b82525050565b5f602082019050610a755f830184610a53565b92915050565b610a84816109d7565b82525050565b5f602082019050610a9d5f830184610a7b565b92915050565b5f805f60608486031215610aba57610ab9610979565b5b5f610ac7868287016109c3565b9350506020610ad8868287016109c3565b9250506040610ae9868287016109f6565b9150509250925092565b5f60ff82169050919050565b610b0881610af3565b82525050565b5f602082019050610b215f830184610aff565b92915050565b5f60208284031215610b3c57610b3b610979565b5b5f610b49848285016109c3565b91505092915050565b5f8060408385031215610b6857610b67610979565b5b5f610b75858286016109c3565b9250506020610b86858286016109c3565b9150509250929050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f6002820490506001821680610bd457607f821691505b602082108103610be757610be6610b90565b5b50919050565b7f45524332303a207472616e7366657220616d6f756e74206578636565647320625f8201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b5f610c476026836108d9565b9150610c5282610bed565b604082019050919050565b5f6020820190508181035f830152610c7481610c3b565b9050919050565b7f45524332303a207472616e7366657220616d6f756e74206578636565647320615f8201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b5f610cd56028836108d9565b9150610ce082610c7b565b604082019050919050565b5f6020820190508181035f830152610d0281610cc9565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f610d40826109d7565b9150610d4b836109d7565b9250828203905081811115610d6357610d62610d09565b5b92915050565b5f610d73826109d7565b9150610d7e836109d7565b9250828201905080821115610d9657610d95610d09565b5b9291505056fea2646970667358221220279345e78aa756df0f261c165289eeb756e8e65e3a8d7e4ab176637da3e5f52564736f6c63430008140033
Loading

0 comments on commit 954bd21

Please sign in to comment.