diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 86167ad4d5..0000000000 --- a/.gitmodules +++ /dev/null @@ -1,4 +0,0 @@ -[submodule "contracts/lib/openzeppelin-contracts"] - path = contracts/lib/openzeppelin-contracts - url = https://github.com/OpenZeppelin/openzeppelin-contracts.git - branch = v5.4.0 diff --git a/Taskfile.yml b/Taskfile.yml index ffc67bd0db..de8ca8c54c 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -147,16 +147,14 @@ tasks: desc: Run golangci-lint with auto-fix where possible cmd: ./scripts/lint_fix.sh + # todo(JonathanOppenheimer): remove this task once we have migrated to the new contract testing framework setup-contracts: desc: Set up contracts by compiling Solidity contracts and generating Go bindings dir: ./contracts cmds: - # Keep npm/Hardhat compilation for existing TypeScript tests (Phase 2-3 migration) - cmd: npm ci - cmd: npx hardhat clean - cmd: npx hardhat compile - # New: Compile contracts with solc and generate Go bindings - - cmd: go generate ./... shellcheck: desc: Run shellcheck static analysis on all shell scripts with version management diff --git a/contracts/bindings/gen_erc20nativeminter.go b/contracts/bindings/gen_erc20nativeminter.go deleted file mode 100644 index d3d08f1c53..0000000000 --- a/contracts/bindings/gen_erc20nativeminter.go +++ /dev/null @@ -1,1537 +0,0 @@ -// Code generated - DO NOT EDIT. -// This file is a generated binding and any manual changes will be lost. - -package bindings - -import ( - "errors" - "math/big" - "strings" - - ethereum "github.com/ava-labs/libevm" - "github.com/ava-labs/libevm/accounts/abi" - "github.com/ava-labs/libevm/accounts/abi/bind" - "github.com/ava-labs/libevm/common" - "github.com/ava-labs/libevm/core/types" - "github.com/ava-labs/libevm/event" -) - -// Reference imports to suppress errors if they are not otherwise used. -var ( - _ = errors.New - _ = big.NewInt - _ = strings.NewReader - _ = ethereum.NotFound - _ = bind.Bind - _ = common.Big1 - _ = types.BloomLookup - _ = event.NewSubscription - _ = abi.ConvertType -) - -// ERC20NativeMinterMetaData contains all meta data concerning the ERC20NativeMinter contract. -var ERC20NativeMinterMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"initSupply\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"allowance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"needed\",\"type\":\"uint256\"}],\"name\":\"ERC20InsufficientAllowance\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"needed\",\"type\":\"uint256\"}],\"name\":\"ERC20InsufficientBalance\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"approver\",\"type\":\"address\"}],\"name\":\"ERC20InvalidApprover\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"}],\"name\":\"ERC20InvalidReceiver\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"ERC20InvalidSender\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"ERC20InvalidSpender\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"OwnableInvalidOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"OwnableUnauthorizedAccount\",\"type\":\"error\"},{\"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\":\"dst\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"wad\",\"type\":\"uint256\"}],\"name\":\"Deposit\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"src\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"wad\",\"type\":\"uint256\"}],\"name\":\"Mintdrawal\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"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\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"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\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"deposit\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"isAdmin\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"isEnabled\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"isManager\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"wad\",\"type\":\"uint256\"}],\"name\":\"mintdraw\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"revoke\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setEnabled\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"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\":\"view\",\"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\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x608060405273020000000000000000000000000000000000000160075f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550348015610063575f5ffd5b506040516125fc3803806125fc833981810160405281019061008591906105ac565b730200000000000000000000000000000000000001336040518060400160405280601681526020017f45524332304e61746976654d696e746572546f6b656e000000000000000000008152506040518060400160405280600481526020017f584d504c000000000000000000000000000000000000000000000000000000008152508160039081610116919061080b565b508060049081610126919061080b565b5050505f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610199575f6040517f1e4fbdf70000000000000000000000000000000000000000000000000000000081526004016101909190610919565b60405180910390fd5b6101a88161020d60201b60201c565b508060065f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506102076101fb6102d060201b60201c565b826102d760201b60201c565b506109ef565b5f60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508160055f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b5f33905090565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610347575f6040517fec442f0500000000000000000000000000000000000000000000000000000000815260040161033e9190610919565b60405180910390fd5b6103585f838361035c60201b60201c565b5050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036103ac578060025f8282546103a0919061095f565b9250508190555061047a565b5f5f5f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905081811015610435578381836040517fe450d38c00000000000000000000000000000000000000000000000000000000815260040161042c939291906109a1565b60405180910390fd5b8181035f5f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2081905550505b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036104c1578060025f828254039250508190555061050b565b805f5f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825401925050819055505b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161056891906109d6565b60405180910390a3505050565b5f5ffd5b5f819050919050565b61058b81610579565b8114610595575f5ffd5b50565b5f815190506105a681610582565b92915050565b5f602082840312156105c1576105c0610575565b5b5f6105ce84828501610598565b91505092915050565b5f81519050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168061065257607f821691505b6020821081036106655761066461060e565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f600883026106c77fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8261068c565b6106d1868361068c565b95508019841693508086168417925050509392505050565b5f819050919050565b5f61070c61070761070284610579565b6106e9565b610579565b9050919050565b5f819050919050565b610725836106f2565b61073961073182610713565b848454610698565b825550505050565b5f5f905090565b610750610741565b61075b81848461071c565b505050565b5b8181101561077e576107735f82610748565b600181019050610761565b5050565b601f8211156107c3576107948161066b565b61079d8461067d565b810160208510156107ac578190505b6107c06107b88561067d565b830182610760565b50505b505050565b5f82821c905092915050565b5f6107e35f19846008026107c8565b1980831691505092915050565b5f6107fb83836107d4565b9150826002028217905092915050565b610814826105d7565b67ffffffffffffffff81111561082d5761082c6105e1565b5b610837825461063b565b610842828285610782565b5f60209050601f831160018114610873575f8415610861578287015190505b61086b85826107f0565b8655506108d2565b601f1984166108818661066b565b5f5b828110156108a857848901518255600182019150602085019450602081019050610883565b868310156108c557848901516108c1601f8916826107d4565b8355505b6001600288020188555050505b505050505050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610903826108da565b9050919050565b610913816108f9565b82525050565b5f60208201905061092c5f83018461090a565b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f61096982610579565b915061097483610579565b925082820190508082111561098c5761098b610932565b5b92915050565b61099b81610579565b82525050565b5f6060820190506109b45f83018661090a565b6109c16020830185610992565b6109ce6040830184610992565b949350505050565b5f6020820190506109e95f830184610992565b92915050565b611c00806109fc5f395ff3fe60806040526004361061013f575f3560e01c8063715018a6116100b5578063a9059cbb1161006e578063a9059cbb14610447578063d0e30db014610483578063d0ebdbe71461048d578063dd62ed3e146104b5578063f2fde38b146104f1578063f3ae2415146105195761013f565b8063715018a61461035157806374a8f103146103675780638da5cb5b1461038f5780639015d371146103b957806395d89b41146103f55780639dc29fac1461041f5761013f565b806323b872dd1161010757806323b872dd1461022357806324d7806c1461025f578063313ce5671461029b57806340c10f19146102c5578063704b6c02146102ed57806370a08231146103155761013f565b80630356b6cd1461014357806306fdde031461016b578063095ea7b3146101955780630aaf7043146101d157806318160ddd146101f9575b5f5ffd5b34801561014e575f5ffd5b5061016960048036038101906101649190611747565b610555565b005b348015610176575f5ffd5b5061017f61064e565b60405161018c91906117e2565b60405180910390f35b3480156101a0575f5ffd5b506101bb60048036038101906101b6919061185c565b6106de565b6040516101c891906118b4565b60405180910390f35b3480156101dc575f5ffd5b506101f760048036038101906101f291906118cd565b610700565b005b348015610204575f5ffd5b5061020d610714565b60405161021a9190611907565b60405180910390f35b34801561022e575f5ffd5b5061024960048036038101906102449190611920565b61071d565b60405161025691906118b4565b60405180910390f35b34801561026a575f5ffd5b50610285600480360381019061028091906118cd565b61074b565b60405161029291906118b4565b60405180910390f35b3480156102a6575f5ffd5b506102af6107f4565b6040516102bc919061198b565b60405180910390f35b3480156102d0575f5ffd5b506102eb60048036038101906102e6919061185c565b6107fc565b005b3480156102f8575f5ffd5b50610313600480360381019061030e91906118cd565b610812565b005b348015610320575f5ffd5b5061033b600480360381019061033691906118cd565b610826565b6040516103489190611907565b60405180910390f35b34801561035c575f5ffd5b5061036561086b565b005b348015610372575f5ffd5b5061038d600480360381019061038891906118cd565b61087e565b005b34801561039a575f5ffd5b506103a3610892565b6040516103b091906119b3565b60405180910390f35b3480156103c4575f5ffd5b506103df60048036038101906103da91906118cd565b6108ba565b6040516103ec91906118b4565b60405180910390f35b348015610400575f5ffd5b50610409610963565b60405161041691906117e2565b60405180910390f35b34801561042a575f5ffd5b506104456004803603810190610440919061185c565b6109f3565b005b348015610452575f5ffd5b5061046d6004803603810190610468919061185c565b610a09565b60405161047a91906118b4565b60405180910390f35b61048b610a2b565b005b348015610498575f5ffd5b506104b360048036038101906104ae91906118cd565b610aeb565b005b3480156104c0575f5ffd5b506104db60048036038101906104d691906119cc565b610aff565b6040516104e89190611907565b60405180910390f35b3480156104fc575f5ffd5b50610517600480360381019061051291906118cd565b610b81565b005b348015610524575f5ffd5b5061053f600480360381019061053a91906118cd565b610c05565b60405161054c91906118b4565b60405180910390f35b610566610560610cae565b82610cb5565b60075f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16634f5aaaba6105ab610cae565b836040518363ffffffff1660e01b81526004016105c9929190611a0a565b5f604051808303815f87803b1580156105e0575f5ffd5b505af11580156105f2573d5f5f3e3d5ffd5b505050506105fe610cae565b73ffffffffffffffffffffffffffffffffffffffff167f25bedde6c8ebd3a89b719a16299dbfe271c7bffa42fe1ac1a52e15ab0cb767e6826040516106439190611907565b60405180910390a250565b60606003805461065d90611a5e565b80601f016020809104026020016040519081016040528092919081815260200182805461068990611a5e565b80156106d45780601f106106ab576101008083540402835291602001916106d4565b820191905f5260205f20905b8154815290600101906020018083116106b757829003601f168201915b5050505050905090565b5f5f6106e8610cae565b90506106f5818585610d34565b600191505092915050565b610708610d46565b61071181610dcd565b50565b5f600254905090565b5f5f610727610cae565b9050610734858285610e57565b61073f858585610eea565b60019150509392505050565b5f5f60065f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663eb54dae1846040518263ffffffff1660e01b81526004016107a791906119b3565b602060405180830381865afa1580156107c2573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107e69190611aa2565b905060028114915050919050565b5f6012905090565b610804610d46565b61080e8282610fda565b5050565b61081a610d46565b61082381611059565b50565b5f5f5f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050919050565b610873610d46565b61087c5f6110e3565b565b610886610d46565b61088f816111a6565b50565b5f60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b5f5f60065f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663eb54dae1846040518263ffffffff1660e01b815260040161091691906119b3565b602060405180830381865afa158015610931573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109559190611aa2565b90505f811415915050919050565b60606004805461097290611a5e565b80601f016020809104026020016040519081016040528092919081815260200182805461099e90611a5e565b80156109e95780601f106109c0576101008083540402835291602001916109e9565b820191905f5260205f20905b8154815290600101906020018083116109cc57829003601f168201915b5050505050905090565b6109fb610d46565b610a058282610cb5565b5050565b5f5f610a13610cae565b9050610a20818585610eea565b600191505092915050565b73010000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166108fc3490811502906040515f60405180830381858888f19350505050158015610a82573d5f5f3e3d5ffd5b50610a94610a8e610cae565b34610fda565b610a9c610cae565b73ffffffffffffffffffffffffffffffffffffffff167fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c34604051610ae19190611907565b60405180910390a2565b610af3610d46565b610afc8161129e565b50565b5f60015f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905092915050565b610b89610d46565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610bf9575f6040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600401610bf091906119b3565b60405180910390fd5b610c02816110e3565b50565b5f5f60065f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663eb54dae1846040518263ffffffff1660e01b8152600401610c6191906119b3565b602060405180830381865afa158015610c7c573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ca09190611aa2565b905060038114915050919050565b5f33905090565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610d25575f6040517f96c6fd1e000000000000000000000000000000000000000000000000000000008152600401610d1c91906119b3565b60405180910390fd5b610d30825f83611328565b5050565b610d418383836001611541565b505050565b610d4e610cae565b73ffffffffffffffffffffffffffffffffffffffff16610d6c610892565b73ffffffffffffffffffffffffffffffffffffffff1614610dcb57610d8f610cae565b6040517f118cdaa7000000000000000000000000000000000000000000000000000000008152600401610dc291906119b3565b60405180910390fd5b565b60065f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630aaf7043826040518263ffffffff1660e01b8152600401610e2791906119b3565b5f604051808303815f87803b158015610e3e575f5ffd5b505af1158015610e50573d5f5f3e3d5ffd5b5050505050565b5f610e628484610aff565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811015610ee45781811015610ed5578281836040517ffb8f41b2000000000000000000000000000000000000000000000000000000008152600401610ecc93929190611acd565b60405180910390fd5b610ee384848484035f611541565b5b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610f5a575f6040517f96c6fd1e000000000000000000000000000000000000000000000000000000008152600401610f5191906119b3565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610fca575f6040517fec442f05000000000000000000000000000000000000000000000000000000008152600401610fc191906119b3565b60405180910390fd5b610fd5838383611328565b505050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361104a575f6040517fec442f0500000000000000000000000000000000000000000000000000000000815260040161104191906119b3565b60405180910390fd5b6110555f8383611328565b5050565b60065f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663704b6c02826040518263ffffffff1660e01b81526004016110b391906119b3565b5f604051808303815f87803b1580156110ca575f5ffd5b505af11580156110dc573d5f5f3e3d5ffd5b5050505050565b5f60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508160055f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1603611214576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161120b90611b4c565b60405180910390fd5b60065f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638c6bfb3b826040518263ffffffff1660e01b815260040161126e91906119b3565b5f604051808303815f87803b158015611285575f5ffd5b505af1158015611297573d5f5f3e3d5ffd5b5050505050565b60065f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d0ebdbe7826040518263ffffffff1660e01b81526004016112f891906119b3565b5f604051808303815f87803b15801561130f575f5ffd5b505af1158015611321573d5f5f3e3d5ffd5b5050505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603611378578060025f82825461136c9190611b97565b92505081905550611446565b5f5f5f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905081811015611401578381836040517fe450d38c0000000000000000000000000000000000000000000000000000000081526004016113f893929190611acd565b60405180910390fd5b8181035f5f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2081905550505b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361148d578060025f82825403925050819055506114d7565b805f5f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825401925050819055505b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516115349190611907565b60405180910390a3505050565b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16036115b1575f6040517fe602df050000000000000000000000000000000000000000000000000000000081526004016115a891906119b3565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603611621575f6040517f94280d6200000000000000000000000000000000000000000000000000000000815260040161161891906119b3565b60405180910390fd5b8160015f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2081905550801561170a578273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040516117019190611907565b60405180910390a35b50505050565b5f5ffd5b5f819050919050565b61172681611714565b8114611730575f5ffd5b50565b5f813590506117418161171d565b92915050565b5f6020828403121561175c5761175b611710565b5b5f61176984828501611733565b91505092915050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f601f19601f8301169050919050565b5f6117b482611772565b6117be818561177c565b93506117ce81856020860161178c565b6117d78161179a565b840191505092915050565b5f6020820190508181035f8301526117fa81846117aa565b905092915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61182b82611802565b9050919050565b61183b81611821565b8114611845575f5ffd5b50565b5f8135905061185681611832565b92915050565b5f5f6040838503121561187257611871611710565b5b5f61187f85828601611848565b925050602061189085828601611733565b9150509250929050565b5f8115159050919050565b6118ae8161189a565b82525050565b5f6020820190506118c75f8301846118a5565b92915050565b5f602082840312156118e2576118e1611710565b5b5f6118ef84828501611848565b91505092915050565b61190181611714565b82525050565b5f60208201905061191a5f8301846118f8565b92915050565b5f5f5f6060848603121561193757611936611710565b5b5f61194486828701611848565b935050602061195586828701611848565b925050604061196686828701611733565b9150509250925092565b5f60ff82169050919050565b61198581611970565b82525050565b5f60208201905061199e5f83018461197c565b92915050565b6119ad81611821565b82525050565b5f6020820190506119c65f8301846119a4565b92915050565b5f5f604083850312156119e2576119e1611710565b5b5f6119ef85828601611848565b9250506020611a0085828601611848565b9150509250929050565b5f604082019050611a1d5f8301856119a4565b611a2a60208301846118f8565b9392505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f6002820490506001821680611a7557607f821691505b602082108103611a8857611a87611a31565b5b50919050565b5f81519050611a9c8161171d565b92915050565b5f60208284031215611ab757611ab6611710565b5b5f611ac484828501611a8e565b91505092915050565b5f606082019050611ae05f8301866119a4565b611aed60208301856118f8565b611afa60408301846118f8565b949350505050565b7f63616e6e6f74207265766f6b65206f776e20726f6c65000000000000000000005f82015250565b5f611b3660168361177c565b9150611b4182611b02565b602082019050919050565b5f6020820190508181035f830152611b6381611b2a565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f611ba182611714565b9150611bac83611714565b9250828201905080821115611bc457611bc3611b6a565b5b9291505056fea2646970667358221220fca92aaeb8dc3d59a0a4fbaa4c4cb6ff44ab43947a730765492db15ebc96e77364736f6c634300081e0033", -} - -// ERC20NativeMinterABI is the input ABI used to generate the binding from. -// Deprecated: Use ERC20NativeMinterMetaData.ABI instead. -var ERC20NativeMinterABI = ERC20NativeMinterMetaData.ABI - -// ERC20NativeMinterBin is the compiled bytecode used for deploying new contracts. -// Deprecated: Use ERC20NativeMinterMetaData.Bin instead. -var ERC20NativeMinterBin = ERC20NativeMinterMetaData.Bin - -// DeployERC20NativeMinter deploys a new Ethereum contract, binding an instance of ERC20NativeMinter to it. -func DeployERC20NativeMinter(auth *bind.TransactOpts, backend bind.ContractBackend, initSupply *big.Int) (common.Address, *types.Transaction, *ERC20NativeMinter, error) { - parsed, err := ERC20NativeMinterMetaData.GetAbi() - if err != nil { - return common.Address{}, nil, nil, err - } - if parsed == nil { - return common.Address{}, nil, nil, errors.New("GetABI returned nil") - } - - address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(ERC20NativeMinterBin), backend, initSupply) - if err != nil { - return common.Address{}, nil, nil, err - } - return address, tx, &ERC20NativeMinter{ERC20NativeMinterCaller: ERC20NativeMinterCaller{contract: contract}, ERC20NativeMinterTransactor: ERC20NativeMinterTransactor{contract: contract}, ERC20NativeMinterFilterer: ERC20NativeMinterFilterer{contract: contract}}, nil -} - -// ERC20NativeMinter is an auto generated Go binding around an Ethereum contract. -type ERC20NativeMinter struct { - ERC20NativeMinterCaller // Read-only binding to the contract - ERC20NativeMinterTransactor // Write-only binding to the contract - ERC20NativeMinterFilterer // Log filterer for contract events -} - -// ERC20NativeMinterCaller is an auto generated read-only Go binding around an Ethereum contract. -type ERC20NativeMinterCaller struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// ERC20NativeMinterTransactor is an auto generated write-only Go binding around an Ethereum contract. -type ERC20NativeMinterTransactor struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// ERC20NativeMinterFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type ERC20NativeMinterFilterer struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// ERC20NativeMinterSession is an auto generated Go binding around an Ethereum contract, -// with pre-set call and transact options. -type ERC20NativeMinterSession struct { - Contract *ERC20NativeMinter // Generic contract binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// ERC20NativeMinterCallerSession is an auto generated read-only Go binding around an Ethereum contract, -// with pre-set call options. -type ERC20NativeMinterCallerSession struct { - Contract *ERC20NativeMinterCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session -} - -// ERC20NativeMinterTransactorSession is an auto generated write-only Go binding around an Ethereum contract, -// with pre-set transact options. -type ERC20NativeMinterTransactorSession struct { - Contract *ERC20NativeMinterTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// ERC20NativeMinterRaw is an auto generated low-level Go binding around an Ethereum contract. -type ERC20NativeMinterRaw struct { - Contract *ERC20NativeMinter // Generic contract binding to access the raw methods on -} - -// ERC20NativeMinterCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type ERC20NativeMinterCallerRaw struct { - Contract *ERC20NativeMinterCaller // Generic read-only contract binding to access the raw methods on -} - -// ERC20NativeMinterTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type ERC20NativeMinterTransactorRaw struct { - Contract *ERC20NativeMinterTransactor // Generic write-only contract binding to access the raw methods on -} - -// NewERC20NativeMinter creates a new instance of ERC20NativeMinter, bound to a specific deployed contract. -func NewERC20NativeMinter(address common.Address, backend bind.ContractBackend) (*ERC20NativeMinter, error) { - contract, err := bindERC20NativeMinter(address, backend, backend, backend) - if err != nil { - return nil, err - } - return &ERC20NativeMinter{ERC20NativeMinterCaller: ERC20NativeMinterCaller{contract: contract}, ERC20NativeMinterTransactor: ERC20NativeMinterTransactor{contract: contract}, ERC20NativeMinterFilterer: ERC20NativeMinterFilterer{contract: contract}}, nil -} - -// NewERC20NativeMinterCaller creates a new read-only instance of ERC20NativeMinter, bound to a specific deployed contract. -func NewERC20NativeMinterCaller(address common.Address, caller bind.ContractCaller) (*ERC20NativeMinterCaller, error) { - contract, err := bindERC20NativeMinter(address, caller, nil, nil) - if err != nil { - return nil, err - } - return &ERC20NativeMinterCaller{contract: contract}, nil -} - -// NewERC20NativeMinterTransactor creates a new write-only instance of ERC20NativeMinter, bound to a specific deployed contract. -func NewERC20NativeMinterTransactor(address common.Address, transactor bind.ContractTransactor) (*ERC20NativeMinterTransactor, error) { - contract, err := bindERC20NativeMinter(address, nil, transactor, nil) - if err != nil { - return nil, err - } - return &ERC20NativeMinterTransactor{contract: contract}, nil -} - -// NewERC20NativeMinterFilterer creates a new log filterer instance of ERC20NativeMinter, bound to a specific deployed contract. -func NewERC20NativeMinterFilterer(address common.Address, filterer bind.ContractFilterer) (*ERC20NativeMinterFilterer, error) { - contract, err := bindERC20NativeMinter(address, nil, nil, filterer) - if err != nil { - return nil, err - } - return &ERC20NativeMinterFilterer{contract: contract}, nil -} - -// bindERC20NativeMinter binds a generic wrapper to an already deployed contract. -func bindERC20NativeMinter(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := ERC20NativeMinterMetaData.GetAbi() - if err != nil { - return nil, err - } - return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_ERC20NativeMinter *ERC20NativeMinterRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _ERC20NativeMinter.Contract.ERC20NativeMinterCaller.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_ERC20NativeMinter *ERC20NativeMinterRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.ERC20NativeMinterTransactor.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_ERC20NativeMinter *ERC20NativeMinterRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.ERC20NativeMinterTransactor.contract.Transact(opts, method, params...) -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_ERC20NativeMinter *ERC20NativeMinterCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _ERC20NativeMinter.Contract.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_ERC20NativeMinter *ERC20NativeMinterTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_ERC20NativeMinter *ERC20NativeMinterTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.contract.Transact(opts, method, params...) -} - -// Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. -// -// Solidity: function allowance(address owner, address spender) view returns(uint256) -func (_ERC20NativeMinter *ERC20NativeMinterCaller) Allowance(opts *bind.CallOpts, owner common.Address, spender common.Address) (*big.Int, error) { - var out []interface{} - err := _ERC20NativeMinter.contract.Call(opts, &out, "allowance", owner, spender) - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. -// -// Solidity: function allowance(address owner, address spender) view returns(uint256) -func (_ERC20NativeMinter *ERC20NativeMinterSession) Allowance(owner common.Address, spender common.Address) (*big.Int, error) { - return _ERC20NativeMinter.Contract.Allowance(&_ERC20NativeMinter.CallOpts, owner, spender) -} - -// Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. -// -// Solidity: function allowance(address owner, address spender) view returns(uint256) -func (_ERC20NativeMinter *ERC20NativeMinterCallerSession) Allowance(owner common.Address, spender common.Address) (*big.Int, error) { - return _ERC20NativeMinter.Contract.Allowance(&_ERC20NativeMinter.CallOpts, owner, spender) -} - -// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. -// -// Solidity: function balanceOf(address account) view returns(uint256) -func (_ERC20NativeMinter *ERC20NativeMinterCaller) BalanceOf(opts *bind.CallOpts, account common.Address) (*big.Int, error) { - var out []interface{} - err := _ERC20NativeMinter.contract.Call(opts, &out, "balanceOf", account) - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. -// -// Solidity: function balanceOf(address account) view returns(uint256) -func (_ERC20NativeMinter *ERC20NativeMinterSession) BalanceOf(account common.Address) (*big.Int, error) { - return _ERC20NativeMinter.Contract.BalanceOf(&_ERC20NativeMinter.CallOpts, account) -} - -// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. -// -// Solidity: function balanceOf(address account) view returns(uint256) -func (_ERC20NativeMinter *ERC20NativeMinterCallerSession) BalanceOf(account common.Address) (*big.Int, error) { - return _ERC20NativeMinter.Contract.BalanceOf(&_ERC20NativeMinter.CallOpts, account) -} - -// Decimals is a free data retrieval call binding the contract method 0x313ce567. -// -// Solidity: function decimals() view returns(uint8) -func (_ERC20NativeMinter *ERC20NativeMinterCaller) Decimals(opts *bind.CallOpts) (uint8, error) { - var out []interface{} - err := _ERC20NativeMinter.contract.Call(opts, &out, "decimals") - - if err != nil { - return *new(uint8), err - } - - out0 := *abi.ConvertType(out[0], new(uint8)).(*uint8) - - return out0, err - -} - -// Decimals is a free data retrieval call binding the contract method 0x313ce567. -// -// Solidity: function decimals() view returns(uint8) -func (_ERC20NativeMinter *ERC20NativeMinterSession) Decimals() (uint8, error) { - return _ERC20NativeMinter.Contract.Decimals(&_ERC20NativeMinter.CallOpts) -} - -// Decimals is a free data retrieval call binding the contract method 0x313ce567. -// -// Solidity: function decimals() view returns(uint8) -func (_ERC20NativeMinter *ERC20NativeMinterCallerSession) Decimals() (uint8, error) { - return _ERC20NativeMinter.Contract.Decimals(&_ERC20NativeMinter.CallOpts) -} - -// IsAdmin is a free data retrieval call binding the contract method 0x24d7806c. -// -// Solidity: function isAdmin(address addr) view returns(bool) -func (_ERC20NativeMinter *ERC20NativeMinterCaller) IsAdmin(opts *bind.CallOpts, addr common.Address) (bool, error) { - var out []interface{} - err := _ERC20NativeMinter.contract.Call(opts, &out, "isAdmin", addr) - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// IsAdmin is a free data retrieval call binding the contract method 0x24d7806c. -// -// Solidity: function isAdmin(address addr) view returns(bool) -func (_ERC20NativeMinter *ERC20NativeMinterSession) IsAdmin(addr common.Address) (bool, error) { - return _ERC20NativeMinter.Contract.IsAdmin(&_ERC20NativeMinter.CallOpts, addr) -} - -// IsAdmin is a free data retrieval call binding the contract method 0x24d7806c. -// -// Solidity: function isAdmin(address addr) view returns(bool) -func (_ERC20NativeMinter *ERC20NativeMinterCallerSession) IsAdmin(addr common.Address) (bool, error) { - return _ERC20NativeMinter.Contract.IsAdmin(&_ERC20NativeMinter.CallOpts, addr) -} - -// IsEnabled is a free data retrieval call binding the contract method 0x9015d371. -// -// Solidity: function isEnabled(address addr) view returns(bool) -func (_ERC20NativeMinter *ERC20NativeMinterCaller) IsEnabled(opts *bind.CallOpts, addr common.Address) (bool, error) { - var out []interface{} - err := _ERC20NativeMinter.contract.Call(opts, &out, "isEnabled", addr) - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// IsEnabled is a free data retrieval call binding the contract method 0x9015d371. -// -// Solidity: function isEnabled(address addr) view returns(bool) -func (_ERC20NativeMinter *ERC20NativeMinterSession) IsEnabled(addr common.Address) (bool, error) { - return _ERC20NativeMinter.Contract.IsEnabled(&_ERC20NativeMinter.CallOpts, addr) -} - -// IsEnabled is a free data retrieval call binding the contract method 0x9015d371. -// -// Solidity: function isEnabled(address addr) view returns(bool) -func (_ERC20NativeMinter *ERC20NativeMinterCallerSession) IsEnabled(addr common.Address) (bool, error) { - return _ERC20NativeMinter.Contract.IsEnabled(&_ERC20NativeMinter.CallOpts, addr) -} - -// IsManager is a free data retrieval call binding the contract method 0xf3ae2415. -// -// Solidity: function isManager(address addr) view returns(bool) -func (_ERC20NativeMinter *ERC20NativeMinterCaller) IsManager(opts *bind.CallOpts, addr common.Address) (bool, error) { - var out []interface{} - err := _ERC20NativeMinter.contract.Call(opts, &out, "isManager", addr) - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// IsManager is a free data retrieval call binding the contract method 0xf3ae2415. -// -// Solidity: function isManager(address addr) view returns(bool) -func (_ERC20NativeMinter *ERC20NativeMinterSession) IsManager(addr common.Address) (bool, error) { - return _ERC20NativeMinter.Contract.IsManager(&_ERC20NativeMinter.CallOpts, addr) -} - -// IsManager is a free data retrieval call binding the contract method 0xf3ae2415. -// -// Solidity: function isManager(address addr) view returns(bool) -func (_ERC20NativeMinter *ERC20NativeMinterCallerSession) IsManager(addr common.Address) (bool, error) { - return _ERC20NativeMinter.Contract.IsManager(&_ERC20NativeMinter.CallOpts, addr) -} - -// Name is a free data retrieval call binding the contract method 0x06fdde03. -// -// Solidity: function name() view returns(string) -func (_ERC20NativeMinter *ERC20NativeMinterCaller) Name(opts *bind.CallOpts) (string, error) { - var out []interface{} - err := _ERC20NativeMinter.contract.Call(opts, &out, "name") - - if err != nil { - return *new(string), err - } - - out0 := *abi.ConvertType(out[0], new(string)).(*string) - - return out0, err - -} - -// Name is a free data retrieval call binding the contract method 0x06fdde03. -// -// Solidity: function name() view returns(string) -func (_ERC20NativeMinter *ERC20NativeMinterSession) Name() (string, error) { - return _ERC20NativeMinter.Contract.Name(&_ERC20NativeMinter.CallOpts) -} - -// Name is a free data retrieval call binding the contract method 0x06fdde03. -// -// Solidity: function name() view returns(string) -func (_ERC20NativeMinter *ERC20NativeMinterCallerSession) Name() (string, error) { - return _ERC20NativeMinter.Contract.Name(&_ERC20NativeMinter.CallOpts) -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_ERC20NativeMinter *ERC20NativeMinterCaller) Owner(opts *bind.CallOpts) (common.Address, error) { - var out []interface{} - err := _ERC20NativeMinter.contract.Call(opts, &out, "owner") - - if err != nil { - return *new(common.Address), err - } - - out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - - return out0, err - -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_ERC20NativeMinter *ERC20NativeMinterSession) Owner() (common.Address, error) { - return _ERC20NativeMinter.Contract.Owner(&_ERC20NativeMinter.CallOpts) -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_ERC20NativeMinter *ERC20NativeMinterCallerSession) Owner() (common.Address, error) { - return _ERC20NativeMinter.Contract.Owner(&_ERC20NativeMinter.CallOpts) -} - -// Symbol is a free data retrieval call binding the contract method 0x95d89b41. -// -// Solidity: function symbol() view returns(string) -func (_ERC20NativeMinter *ERC20NativeMinterCaller) Symbol(opts *bind.CallOpts) (string, error) { - var out []interface{} - err := _ERC20NativeMinter.contract.Call(opts, &out, "symbol") - - if err != nil { - return *new(string), err - } - - out0 := *abi.ConvertType(out[0], new(string)).(*string) - - return out0, err - -} - -// Symbol is a free data retrieval call binding the contract method 0x95d89b41. -// -// Solidity: function symbol() view returns(string) -func (_ERC20NativeMinter *ERC20NativeMinterSession) Symbol() (string, error) { - return _ERC20NativeMinter.Contract.Symbol(&_ERC20NativeMinter.CallOpts) -} - -// Symbol is a free data retrieval call binding the contract method 0x95d89b41. -// -// Solidity: function symbol() view returns(string) -func (_ERC20NativeMinter *ERC20NativeMinterCallerSession) Symbol() (string, error) { - return _ERC20NativeMinter.Contract.Symbol(&_ERC20NativeMinter.CallOpts) -} - -// TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. -// -// Solidity: function totalSupply() view returns(uint256) -func (_ERC20NativeMinter *ERC20NativeMinterCaller) TotalSupply(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _ERC20NativeMinter.contract.Call(opts, &out, "totalSupply") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. -// -// Solidity: function totalSupply() view returns(uint256) -func (_ERC20NativeMinter *ERC20NativeMinterSession) TotalSupply() (*big.Int, error) { - return _ERC20NativeMinter.Contract.TotalSupply(&_ERC20NativeMinter.CallOpts) -} - -// TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. -// -// Solidity: function totalSupply() view returns(uint256) -func (_ERC20NativeMinter *ERC20NativeMinterCallerSession) TotalSupply() (*big.Int, error) { - return _ERC20NativeMinter.Contract.TotalSupply(&_ERC20NativeMinter.CallOpts) -} - -// Approve is a paid mutator transaction binding the contract method 0x095ea7b3. -// -// Solidity: function approve(address spender, uint256 value) returns(bool) -func (_ERC20NativeMinter *ERC20NativeMinterTransactor) Approve(opts *bind.TransactOpts, spender common.Address, value *big.Int) (*types.Transaction, error) { - return _ERC20NativeMinter.contract.Transact(opts, "approve", spender, value) -} - -// Approve is a paid mutator transaction binding the contract method 0x095ea7b3. -// -// Solidity: function approve(address spender, uint256 value) returns(bool) -func (_ERC20NativeMinter *ERC20NativeMinterSession) Approve(spender common.Address, value *big.Int) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.Approve(&_ERC20NativeMinter.TransactOpts, spender, value) -} - -// Approve is a paid mutator transaction binding the contract method 0x095ea7b3. -// -// Solidity: function approve(address spender, uint256 value) returns(bool) -func (_ERC20NativeMinter *ERC20NativeMinterTransactorSession) Approve(spender common.Address, value *big.Int) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.Approve(&_ERC20NativeMinter.TransactOpts, spender, value) -} - -// Burn is a paid mutator transaction binding the contract method 0x9dc29fac. -// -// Solidity: function burn(address from, uint256 amount) returns() -func (_ERC20NativeMinter *ERC20NativeMinterTransactor) Burn(opts *bind.TransactOpts, from common.Address, amount *big.Int) (*types.Transaction, error) { - return _ERC20NativeMinter.contract.Transact(opts, "burn", from, amount) -} - -// Burn is a paid mutator transaction binding the contract method 0x9dc29fac. -// -// Solidity: function burn(address from, uint256 amount) returns() -func (_ERC20NativeMinter *ERC20NativeMinterSession) Burn(from common.Address, amount *big.Int) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.Burn(&_ERC20NativeMinter.TransactOpts, from, amount) -} - -// Burn is a paid mutator transaction binding the contract method 0x9dc29fac. -// -// Solidity: function burn(address from, uint256 amount) returns() -func (_ERC20NativeMinter *ERC20NativeMinterTransactorSession) Burn(from common.Address, amount *big.Int) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.Burn(&_ERC20NativeMinter.TransactOpts, from, amount) -} - -// Deposit is a paid mutator transaction binding the contract method 0xd0e30db0. -// -// Solidity: function deposit() payable returns() -func (_ERC20NativeMinter *ERC20NativeMinterTransactor) Deposit(opts *bind.TransactOpts) (*types.Transaction, error) { - return _ERC20NativeMinter.contract.Transact(opts, "deposit") -} - -// Deposit is a paid mutator transaction binding the contract method 0xd0e30db0. -// -// Solidity: function deposit() payable returns() -func (_ERC20NativeMinter *ERC20NativeMinterSession) Deposit() (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.Deposit(&_ERC20NativeMinter.TransactOpts) -} - -// Deposit is a paid mutator transaction binding the contract method 0xd0e30db0. -// -// Solidity: function deposit() payable returns() -func (_ERC20NativeMinter *ERC20NativeMinterTransactorSession) Deposit() (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.Deposit(&_ERC20NativeMinter.TransactOpts) -} - -// Mint is a paid mutator transaction binding the contract method 0x40c10f19. -// -// Solidity: function mint(address to, uint256 amount) returns() -func (_ERC20NativeMinter *ERC20NativeMinterTransactor) Mint(opts *bind.TransactOpts, to common.Address, amount *big.Int) (*types.Transaction, error) { - return _ERC20NativeMinter.contract.Transact(opts, "mint", to, amount) -} - -// Mint is a paid mutator transaction binding the contract method 0x40c10f19. -// -// Solidity: function mint(address to, uint256 amount) returns() -func (_ERC20NativeMinter *ERC20NativeMinterSession) Mint(to common.Address, amount *big.Int) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.Mint(&_ERC20NativeMinter.TransactOpts, to, amount) -} - -// Mint is a paid mutator transaction binding the contract method 0x40c10f19. -// -// Solidity: function mint(address to, uint256 amount) returns() -func (_ERC20NativeMinter *ERC20NativeMinterTransactorSession) Mint(to common.Address, amount *big.Int) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.Mint(&_ERC20NativeMinter.TransactOpts, to, amount) -} - -// Mintdraw is a paid mutator transaction binding the contract method 0x0356b6cd. -// -// Solidity: function mintdraw(uint256 wad) returns() -func (_ERC20NativeMinter *ERC20NativeMinterTransactor) Mintdraw(opts *bind.TransactOpts, wad *big.Int) (*types.Transaction, error) { - return _ERC20NativeMinter.contract.Transact(opts, "mintdraw", wad) -} - -// Mintdraw is a paid mutator transaction binding the contract method 0x0356b6cd. -// -// Solidity: function mintdraw(uint256 wad) returns() -func (_ERC20NativeMinter *ERC20NativeMinterSession) Mintdraw(wad *big.Int) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.Mintdraw(&_ERC20NativeMinter.TransactOpts, wad) -} - -// Mintdraw is a paid mutator transaction binding the contract method 0x0356b6cd. -// -// Solidity: function mintdraw(uint256 wad) returns() -func (_ERC20NativeMinter *ERC20NativeMinterTransactorSession) Mintdraw(wad *big.Int) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.Mintdraw(&_ERC20NativeMinter.TransactOpts, wad) -} - -// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. -// -// Solidity: function renounceOwnership() returns() -func (_ERC20NativeMinter *ERC20NativeMinterTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { - return _ERC20NativeMinter.contract.Transact(opts, "renounceOwnership") -} - -// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. -// -// Solidity: function renounceOwnership() returns() -func (_ERC20NativeMinter *ERC20NativeMinterSession) RenounceOwnership() (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.RenounceOwnership(&_ERC20NativeMinter.TransactOpts) -} - -// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. -// -// Solidity: function renounceOwnership() returns() -func (_ERC20NativeMinter *ERC20NativeMinterTransactorSession) RenounceOwnership() (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.RenounceOwnership(&_ERC20NativeMinter.TransactOpts) -} - -// Revoke is a paid mutator transaction binding the contract method 0x74a8f103. -// -// Solidity: function revoke(address addr) returns() -func (_ERC20NativeMinter *ERC20NativeMinterTransactor) Revoke(opts *bind.TransactOpts, addr common.Address) (*types.Transaction, error) { - return _ERC20NativeMinter.contract.Transact(opts, "revoke", addr) -} - -// Revoke is a paid mutator transaction binding the contract method 0x74a8f103. -// -// Solidity: function revoke(address addr) returns() -func (_ERC20NativeMinter *ERC20NativeMinterSession) Revoke(addr common.Address) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.Revoke(&_ERC20NativeMinter.TransactOpts, addr) -} - -// Revoke is a paid mutator transaction binding the contract method 0x74a8f103. -// -// Solidity: function revoke(address addr) returns() -func (_ERC20NativeMinter *ERC20NativeMinterTransactorSession) Revoke(addr common.Address) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.Revoke(&_ERC20NativeMinter.TransactOpts, addr) -} - -// SetAdmin is a paid mutator transaction binding the contract method 0x704b6c02. -// -// Solidity: function setAdmin(address addr) returns() -func (_ERC20NativeMinter *ERC20NativeMinterTransactor) SetAdmin(opts *bind.TransactOpts, addr common.Address) (*types.Transaction, error) { - return _ERC20NativeMinter.contract.Transact(opts, "setAdmin", addr) -} - -// SetAdmin is a paid mutator transaction binding the contract method 0x704b6c02. -// -// Solidity: function setAdmin(address addr) returns() -func (_ERC20NativeMinter *ERC20NativeMinterSession) SetAdmin(addr common.Address) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.SetAdmin(&_ERC20NativeMinter.TransactOpts, addr) -} - -// SetAdmin is a paid mutator transaction binding the contract method 0x704b6c02. -// -// Solidity: function setAdmin(address addr) returns() -func (_ERC20NativeMinter *ERC20NativeMinterTransactorSession) SetAdmin(addr common.Address) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.SetAdmin(&_ERC20NativeMinter.TransactOpts, addr) -} - -// SetEnabled is a paid mutator transaction binding the contract method 0x0aaf7043. -// -// Solidity: function setEnabled(address addr) returns() -func (_ERC20NativeMinter *ERC20NativeMinterTransactor) SetEnabled(opts *bind.TransactOpts, addr common.Address) (*types.Transaction, error) { - return _ERC20NativeMinter.contract.Transact(opts, "setEnabled", addr) -} - -// SetEnabled is a paid mutator transaction binding the contract method 0x0aaf7043. -// -// Solidity: function setEnabled(address addr) returns() -func (_ERC20NativeMinter *ERC20NativeMinterSession) SetEnabled(addr common.Address) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.SetEnabled(&_ERC20NativeMinter.TransactOpts, addr) -} - -// SetEnabled is a paid mutator transaction binding the contract method 0x0aaf7043. -// -// Solidity: function setEnabled(address addr) returns() -func (_ERC20NativeMinter *ERC20NativeMinterTransactorSession) SetEnabled(addr common.Address) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.SetEnabled(&_ERC20NativeMinter.TransactOpts, addr) -} - -// SetManager is a paid mutator transaction binding the contract method 0xd0ebdbe7. -// -// Solidity: function setManager(address addr) returns() -func (_ERC20NativeMinter *ERC20NativeMinterTransactor) SetManager(opts *bind.TransactOpts, addr common.Address) (*types.Transaction, error) { - return _ERC20NativeMinter.contract.Transact(opts, "setManager", addr) -} - -// SetManager is a paid mutator transaction binding the contract method 0xd0ebdbe7. -// -// Solidity: function setManager(address addr) returns() -func (_ERC20NativeMinter *ERC20NativeMinterSession) SetManager(addr common.Address) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.SetManager(&_ERC20NativeMinter.TransactOpts, addr) -} - -// SetManager is a paid mutator transaction binding the contract method 0xd0ebdbe7. -// -// Solidity: function setManager(address addr) returns() -func (_ERC20NativeMinter *ERC20NativeMinterTransactorSession) SetManager(addr common.Address) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.SetManager(&_ERC20NativeMinter.TransactOpts, addr) -} - -// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. -// -// Solidity: function transfer(address to, uint256 value) returns(bool) -func (_ERC20NativeMinter *ERC20NativeMinterTransactor) Transfer(opts *bind.TransactOpts, to common.Address, value *big.Int) (*types.Transaction, error) { - return _ERC20NativeMinter.contract.Transact(opts, "transfer", to, value) -} - -// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. -// -// Solidity: function transfer(address to, uint256 value) returns(bool) -func (_ERC20NativeMinter *ERC20NativeMinterSession) Transfer(to common.Address, value *big.Int) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.Transfer(&_ERC20NativeMinter.TransactOpts, to, value) -} - -// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. -// -// Solidity: function transfer(address to, uint256 value) returns(bool) -func (_ERC20NativeMinter *ERC20NativeMinterTransactorSession) Transfer(to common.Address, value *big.Int) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.Transfer(&_ERC20NativeMinter.TransactOpts, to, value) -} - -// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. -// -// Solidity: function transferFrom(address from, address to, uint256 value) returns(bool) -func (_ERC20NativeMinter *ERC20NativeMinterTransactor) TransferFrom(opts *bind.TransactOpts, from common.Address, to common.Address, value *big.Int) (*types.Transaction, error) { - return _ERC20NativeMinter.contract.Transact(opts, "transferFrom", from, to, value) -} - -// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. -// -// Solidity: function transferFrom(address from, address to, uint256 value) returns(bool) -func (_ERC20NativeMinter *ERC20NativeMinterSession) TransferFrom(from common.Address, to common.Address, value *big.Int) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.TransferFrom(&_ERC20NativeMinter.TransactOpts, from, to, value) -} - -// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. -// -// Solidity: function transferFrom(address from, address to, uint256 value) returns(bool) -func (_ERC20NativeMinter *ERC20NativeMinterTransactorSession) TransferFrom(from common.Address, to common.Address, value *big.Int) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.TransferFrom(&_ERC20NativeMinter.TransactOpts, from, to, value) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address newOwner) returns() -func (_ERC20NativeMinter *ERC20NativeMinterTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { - return _ERC20NativeMinter.contract.Transact(opts, "transferOwnership", newOwner) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address newOwner) returns() -func (_ERC20NativeMinter *ERC20NativeMinterSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.TransferOwnership(&_ERC20NativeMinter.TransactOpts, newOwner) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address newOwner) returns() -func (_ERC20NativeMinter *ERC20NativeMinterTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { - return _ERC20NativeMinter.Contract.TransferOwnership(&_ERC20NativeMinter.TransactOpts, newOwner) -} - -// ERC20NativeMinterApprovalIterator is returned from FilterApproval and is used to iterate over the raw logs and unpacked data for Approval events raised by the ERC20NativeMinter contract. -type ERC20NativeMinterApprovalIterator struct { - Event *ERC20NativeMinterApproval // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *ERC20NativeMinterApprovalIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(ERC20NativeMinterApproval) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(ERC20NativeMinterApproval) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *ERC20NativeMinterApprovalIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *ERC20NativeMinterApprovalIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// ERC20NativeMinterApproval represents a Approval event raised by the ERC20NativeMinter contract. -type ERC20NativeMinterApproval struct { - Owner common.Address - Spender common.Address - Value *big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterApproval is a free log retrieval operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925. -// -// Solidity: event Approval(address indexed owner, address indexed spender, uint256 value) -func (_ERC20NativeMinter *ERC20NativeMinterFilterer) FilterApproval(opts *bind.FilterOpts, owner []common.Address, spender []common.Address) (*ERC20NativeMinterApprovalIterator, error) { - - var ownerRule []interface{} - for _, ownerItem := range owner { - ownerRule = append(ownerRule, ownerItem) - } - var spenderRule []interface{} - for _, spenderItem := range spender { - spenderRule = append(spenderRule, spenderItem) - } - - logs, sub, err := _ERC20NativeMinter.contract.FilterLogs(opts, "Approval", ownerRule, spenderRule) - if err != nil { - return nil, err - } - return &ERC20NativeMinterApprovalIterator{contract: _ERC20NativeMinter.contract, event: "Approval", logs: logs, sub: sub}, nil -} - -// WatchApproval is a free log subscription operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925. -// -// Solidity: event Approval(address indexed owner, address indexed spender, uint256 value) -func (_ERC20NativeMinter *ERC20NativeMinterFilterer) WatchApproval(opts *bind.WatchOpts, sink chan<- *ERC20NativeMinterApproval, owner []common.Address, spender []common.Address) (event.Subscription, error) { - - var ownerRule []interface{} - for _, ownerItem := range owner { - ownerRule = append(ownerRule, ownerItem) - } - var spenderRule []interface{} - for _, spenderItem := range spender { - spenderRule = append(spenderRule, spenderItem) - } - - logs, sub, err := _ERC20NativeMinter.contract.WatchLogs(opts, "Approval", ownerRule, spenderRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(ERC20NativeMinterApproval) - if err := _ERC20NativeMinter.contract.UnpackLog(event, "Approval", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseApproval is a log parse operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925. -// -// Solidity: event Approval(address indexed owner, address indexed spender, uint256 value) -func (_ERC20NativeMinter *ERC20NativeMinterFilterer) ParseApproval(log types.Log) (*ERC20NativeMinterApproval, error) { - event := new(ERC20NativeMinterApproval) - if err := _ERC20NativeMinter.contract.UnpackLog(event, "Approval", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// ERC20NativeMinterDepositIterator is returned from FilterDeposit and is used to iterate over the raw logs and unpacked data for Deposit events raised by the ERC20NativeMinter contract. -type ERC20NativeMinterDepositIterator struct { - Event *ERC20NativeMinterDeposit // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *ERC20NativeMinterDepositIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(ERC20NativeMinterDeposit) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(ERC20NativeMinterDeposit) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *ERC20NativeMinterDepositIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *ERC20NativeMinterDepositIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// ERC20NativeMinterDeposit represents a Deposit event raised by the ERC20NativeMinter contract. -type ERC20NativeMinterDeposit struct { - Dst common.Address - Wad *big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterDeposit is a free log retrieval operation binding the contract event 0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c. -// -// Solidity: event Deposit(address indexed dst, uint256 wad) -func (_ERC20NativeMinter *ERC20NativeMinterFilterer) FilterDeposit(opts *bind.FilterOpts, dst []common.Address) (*ERC20NativeMinterDepositIterator, error) { - - var dstRule []interface{} - for _, dstItem := range dst { - dstRule = append(dstRule, dstItem) - } - - logs, sub, err := _ERC20NativeMinter.contract.FilterLogs(opts, "Deposit", dstRule) - if err != nil { - return nil, err - } - return &ERC20NativeMinterDepositIterator{contract: _ERC20NativeMinter.contract, event: "Deposit", logs: logs, sub: sub}, nil -} - -// WatchDeposit is a free log subscription operation binding the contract event 0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c. -// -// Solidity: event Deposit(address indexed dst, uint256 wad) -func (_ERC20NativeMinter *ERC20NativeMinterFilterer) WatchDeposit(opts *bind.WatchOpts, sink chan<- *ERC20NativeMinterDeposit, dst []common.Address) (event.Subscription, error) { - - var dstRule []interface{} - for _, dstItem := range dst { - dstRule = append(dstRule, dstItem) - } - - logs, sub, err := _ERC20NativeMinter.contract.WatchLogs(opts, "Deposit", dstRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(ERC20NativeMinterDeposit) - if err := _ERC20NativeMinter.contract.UnpackLog(event, "Deposit", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseDeposit is a log parse operation binding the contract event 0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c. -// -// Solidity: event Deposit(address indexed dst, uint256 wad) -func (_ERC20NativeMinter *ERC20NativeMinterFilterer) ParseDeposit(log types.Log) (*ERC20NativeMinterDeposit, error) { - event := new(ERC20NativeMinterDeposit) - if err := _ERC20NativeMinter.contract.UnpackLog(event, "Deposit", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// ERC20NativeMinterMintdrawalIterator is returned from FilterMintdrawal and is used to iterate over the raw logs and unpacked data for Mintdrawal events raised by the ERC20NativeMinter contract. -type ERC20NativeMinterMintdrawalIterator struct { - Event *ERC20NativeMinterMintdrawal // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *ERC20NativeMinterMintdrawalIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(ERC20NativeMinterMintdrawal) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(ERC20NativeMinterMintdrawal) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *ERC20NativeMinterMintdrawalIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *ERC20NativeMinterMintdrawalIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// ERC20NativeMinterMintdrawal represents a Mintdrawal event raised by the ERC20NativeMinter contract. -type ERC20NativeMinterMintdrawal struct { - Src common.Address - Wad *big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterMintdrawal is a free log retrieval operation binding the contract event 0x25bedde6c8ebd3a89b719a16299dbfe271c7bffa42fe1ac1a52e15ab0cb767e6. -// -// Solidity: event Mintdrawal(address indexed src, uint256 wad) -func (_ERC20NativeMinter *ERC20NativeMinterFilterer) FilterMintdrawal(opts *bind.FilterOpts, src []common.Address) (*ERC20NativeMinterMintdrawalIterator, error) { - - var srcRule []interface{} - for _, srcItem := range src { - srcRule = append(srcRule, srcItem) - } - - logs, sub, err := _ERC20NativeMinter.contract.FilterLogs(opts, "Mintdrawal", srcRule) - if err != nil { - return nil, err - } - return &ERC20NativeMinterMintdrawalIterator{contract: _ERC20NativeMinter.contract, event: "Mintdrawal", logs: logs, sub: sub}, nil -} - -// WatchMintdrawal is a free log subscription operation binding the contract event 0x25bedde6c8ebd3a89b719a16299dbfe271c7bffa42fe1ac1a52e15ab0cb767e6. -// -// Solidity: event Mintdrawal(address indexed src, uint256 wad) -func (_ERC20NativeMinter *ERC20NativeMinterFilterer) WatchMintdrawal(opts *bind.WatchOpts, sink chan<- *ERC20NativeMinterMintdrawal, src []common.Address) (event.Subscription, error) { - - var srcRule []interface{} - for _, srcItem := range src { - srcRule = append(srcRule, srcItem) - } - - logs, sub, err := _ERC20NativeMinter.contract.WatchLogs(opts, "Mintdrawal", srcRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(ERC20NativeMinterMintdrawal) - if err := _ERC20NativeMinter.contract.UnpackLog(event, "Mintdrawal", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseMintdrawal is a log parse operation binding the contract event 0x25bedde6c8ebd3a89b719a16299dbfe271c7bffa42fe1ac1a52e15ab0cb767e6. -// -// Solidity: event Mintdrawal(address indexed src, uint256 wad) -func (_ERC20NativeMinter *ERC20NativeMinterFilterer) ParseMintdrawal(log types.Log) (*ERC20NativeMinterMintdrawal, error) { - event := new(ERC20NativeMinterMintdrawal) - if err := _ERC20NativeMinter.contract.UnpackLog(event, "Mintdrawal", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// ERC20NativeMinterOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the ERC20NativeMinter contract. -type ERC20NativeMinterOwnershipTransferredIterator struct { - Event *ERC20NativeMinterOwnershipTransferred // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *ERC20NativeMinterOwnershipTransferredIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(ERC20NativeMinterOwnershipTransferred) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(ERC20NativeMinterOwnershipTransferred) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *ERC20NativeMinterOwnershipTransferredIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *ERC20NativeMinterOwnershipTransferredIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// ERC20NativeMinterOwnershipTransferred represents a OwnershipTransferred event raised by the ERC20NativeMinter contract. -type ERC20NativeMinterOwnershipTransferred struct { - PreviousOwner common.Address - NewOwner common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) -func (_ERC20NativeMinter *ERC20NativeMinterFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*ERC20NativeMinterOwnershipTransferredIterator, error) { - - var previousOwnerRule []interface{} - for _, previousOwnerItem := range previousOwner { - previousOwnerRule = append(previousOwnerRule, previousOwnerItem) - } - var newOwnerRule []interface{} - for _, newOwnerItem := range newOwner { - newOwnerRule = append(newOwnerRule, newOwnerItem) - } - - logs, sub, err := _ERC20NativeMinter.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) - if err != nil { - return nil, err - } - return &ERC20NativeMinterOwnershipTransferredIterator{contract: _ERC20NativeMinter.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil -} - -// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) -func (_ERC20NativeMinter *ERC20NativeMinterFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *ERC20NativeMinterOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { - - var previousOwnerRule []interface{} - for _, previousOwnerItem := range previousOwner { - previousOwnerRule = append(previousOwnerRule, previousOwnerItem) - } - var newOwnerRule []interface{} - for _, newOwnerItem := range newOwner { - newOwnerRule = append(newOwnerRule, newOwnerItem) - } - - logs, sub, err := _ERC20NativeMinter.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(ERC20NativeMinterOwnershipTransferred) - if err := _ERC20NativeMinter.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) -func (_ERC20NativeMinter *ERC20NativeMinterFilterer) ParseOwnershipTransferred(log types.Log) (*ERC20NativeMinterOwnershipTransferred, error) { - event := new(ERC20NativeMinterOwnershipTransferred) - if err := _ERC20NativeMinter.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// ERC20NativeMinterTransferIterator is returned from FilterTransfer and is used to iterate over the raw logs and unpacked data for Transfer events raised by the ERC20NativeMinter contract. -type ERC20NativeMinterTransferIterator struct { - Event *ERC20NativeMinterTransfer // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *ERC20NativeMinterTransferIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(ERC20NativeMinterTransfer) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(ERC20NativeMinterTransfer) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *ERC20NativeMinterTransferIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *ERC20NativeMinterTransferIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// ERC20NativeMinterTransfer represents a Transfer event raised by the ERC20NativeMinter contract. -type ERC20NativeMinterTransfer struct { - From common.Address - To common.Address - Value *big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterTransfer is a free log retrieval operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. -// -// Solidity: event Transfer(address indexed from, address indexed to, uint256 value) -func (_ERC20NativeMinter *ERC20NativeMinterFilterer) FilterTransfer(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*ERC20NativeMinterTransferIterator, error) { - - var fromRule []interface{} - for _, fromItem := range from { - fromRule = append(fromRule, fromItem) - } - var toRule []interface{} - for _, toItem := range to { - toRule = append(toRule, toItem) - } - - logs, sub, err := _ERC20NativeMinter.contract.FilterLogs(opts, "Transfer", fromRule, toRule) - if err != nil { - return nil, err - } - return &ERC20NativeMinterTransferIterator{contract: _ERC20NativeMinter.contract, event: "Transfer", logs: logs, sub: sub}, nil -} - -// WatchTransfer is a free log subscription operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. -// -// Solidity: event Transfer(address indexed from, address indexed to, uint256 value) -func (_ERC20NativeMinter *ERC20NativeMinterFilterer) WatchTransfer(opts *bind.WatchOpts, sink chan<- *ERC20NativeMinterTransfer, from []common.Address, to []common.Address) (event.Subscription, error) { - - var fromRule []interface{} - for _, fromItem := range from { - fromRule = append(fromRule, fromItem) - } - var toRule []interface{} - for _, toItem := range to { - toRule = append(toRule, toItem) - } - - logs, sub, err := _ERC20NativeMinter.contract.WatchLogs(opts, "Transfer", fromRule, toRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(ERC20NativeMinterTransfer) - if err := _ERC20NativeMinter.contract.UnpackLog(event, "Transfer", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseTransfer is a log parse operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. -// -// Solidity: event Transfer(address indexed from, address indexed to, uint256 value) -func (_ERC20NativeMinter *ERC20NativeMinterFilterer) ParseTransfer(log types.Log) (*ERC20NativeMinterTransfer, error) { - event := new(ERC20NativeMinterTransfer) - if err := _ERC20NativeMinter.contract.UnpackLog(event, "Transfer", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} diff --git a/contracts/bindings/gen_exampledeployerlist.go b/contracts/bindings/gen_exampledeployerlist.go deleted file mode 100644 index 9ebbdfc963..0000000000 --- a/contracts/bindings/gen_exampledeployerlist.go +++ /dev/null @@ -1,627 +0,0 @@ -// Code generated - DO NOT EDIT. -// This file is a generated binding and any manual changes will be lost. - -package bindings - -import ( - "errors" - "math/big" - "strings" - - ethereum "github.com/ava-labs/libevm" - "github.com/ava-labs/libevm/accounts/abi" - "github.com/ava-labs/libevm/accounts/abi/bind" - "github.com/ava-labs/libevm/common" - "github.com/ava-labs/libevm/core/types" - "github.com/ava-labs/libevm/event" -) - -// Reference imports to suppress errors if they are not otherwise used. -var ( - _ = errors.New - _ = big.NewInt - _ = strings.NewReader - _ = ethereum.NotFound - _ = bind.Bind - _ = common.Big1 - _ = types.BloomLookup - _ = event.NewSubscription - _ = abi.ConvertType -) - -// ExampleDeployerListMetaData contains all meta data concerning the ExampleDeployerList contract. -var ExampleDeployerListMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"OwnableInvalidOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"OwnableUnauthorizedAccount\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"deployContract\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"isAdmin\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"isEnabled\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"isManager\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"revoke\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setEnabled\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x608060405234801561000f575f5ffd5b50730200000000000000000000000000000000000000335f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610096575f6040517f1e4fbdf700000000000000000000000000000000000000000000000000000000815260040161008d91906101ec565b60405180910390fd5b6100a5816100ec60201b60201c565b508060015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610205565b5f5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050815f5f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6101d6826101ad565b9050919050565b6101e6816101cc565b82525050565b5f6020820190506101ff5f8301846101dd565b92915050565b610b64806102125f395ff3fe608060405234801561000f575f5ffd5b50600436106100a7575f3560e01c806374a8f1031161006f57806374a8f103146101275780638da5cb5b146101435780639015d37114610161578063d0ebdbe714610191578063f2fde38b146101ad578063f3ae2415146101c9576100a7565b80630aaf7043146100ab57806324d7806c146100c75780636cd5c39b146100f7578063704b6c0214610101578063715018a61461011d575b5f5ffd5b6100c560048036038101906100c0919061097a565b6101f9565b005b6100e160048036038101906100dc919061097a565b61020d565b6040516100ee91906109bf565b60405180910390f35b6100ff6102b6565b005b61011b6004803603810190610116919061097a565b6102df565b005b6101256102f3565b005b610141600480360381019061013c919061097a565b610306565b005b61014b61031a565b60405161015891906109e7565b60405180910390f35b61017b6004803603810190610176919061097a565b610341565b60405161018891906109bf565b60405180910390f35b6101ab60048036038101906101a6919061097a565b6103ea565b005b6101c760048036038101906101c2919061097a565b6103fe565b005b6101e360048036038101906101de919061097a565b610482565b6040516101f091906109bf565b60405180910390f35b61020161052b565b61020a816105b2565b50565b5f5f60015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663eb54dae1846040518263ffffffff1660e01b815260040161026991906109e7565b602060405180830381865afa158015610284573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102a89190610a33565b905060028114915050919050565b6040516102c290610910565b604051809103905ff0801580156102db573d5f5f3e3d5ffd5b5050565b6102e761052b565b6102f08161063c565b50565b6102fb61052b565b6103045f6106c6565b565b61030e61052b565b61031781610787565b50565b5f5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b5f5f60015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663eb54dae1846040518263ffffffff1660e01b815260040161039d91906109e7565b602060405180830381865afa1580156103b8573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906103dc9190610a33565b90505f811415915050919050565b6103f261052b565b6103fb8161087f565b50565b61040661052b565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610476575f6040517f1e4fbdf700000000000000000000000000000000000000000000000000000000815260040161046d91906109e7565b60405180910390fd5b61047f816106c6565b50565b5f5f60015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663eb54dae1846040518263ffffffff1660e01b81526004016104de91906109e7565b602060405180830381865afa1580156104f9573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061051d9190610a33565b905060038114915050919050565b610533610909565b73ffffffffffffffffffffffffffffffffffffffff1661055161031a565b73ffffffffffffffffffffffffffffffffffffffff16146105b057610574610909565b6040517f118cdaa70000000000000000000000000000000000000000000000000000000081526004016105a791906109e7565b60405180910390fd5b565b60015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630aaf7043826040518263ffffffff1660e01b815260040161060c91906109e7565b5f604051808303815f87803b158015610623575f5ffd5b505af1158015610635573d5f5f3e3d5ffd5b5050505050565b60015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663704b6c02826040518263ffffffff1660e01b815260040161069691906109e7565b5f604051808303815f87803b1580156106ad575f5ffd5b505af11580156106bf573d5f5f3e3d5ffd5b5050505050565b5f5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050815f5f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16036107f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107ec90610ab8565b60405180910390fd5b60015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638c6bfb3b826040518263ffffffff1660e01b815260040161084f91906109e7565b5f604051808303815f87803b158015610866575f5ffd5b505af1158015610878573d5f5f3e3d5ffd5b5050505050565b60015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d0ebdbe7826040518263ffffffff1660e01b81526004016108d991906109e7565b5f604051808303815f87803b1580156108f0575f5ffd5b505af1158015610902573d5f5f3e3d5ffd5b5050505050565b5f33905090565b605880610ad783390190565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61094982610920565b9050919050565b6109598161093f565b8114610963575f5ffd5b50565b5f8135905061097481610950565b92915050565b5f6020828403121561098f5761098e61091c565b5b5f61099c84828501610966565b91505092915050565b5f8115159050919050565b6109b9816109a5565b82525050565b5f6020820190506109d25f8301846109b0565b92915050565b6109e18161093f565b82525050565b5f6020820190506109fa5f8301846109d8565b92915050565b5f819050919050565b610a1281610a00565b8114610a1c575f5ffd5b50565b5f81519050610a2d81610a09565b92915050565b5f60208284031215610a4857610a4761091c565b5b5f610a5584828501610a1f565b91505092915050565b5f82825260208201905092915050565b7f63616e6e6f74207265766f6b65206f776e20726f6c65000000000000000000005f82015250565b5f610aa2601683610a5e565b9150610aad82610a6e565b602082019050919050565b5f6020820190508181035f830152610acf81610a96565b905091905056fe6080604052348015600e575f5ffd5b50603e80601a5f395ff3fe60806040525f5ffdfea26469706673582212204ec2f544eb3d0b4a6bcccfa4c97034822a41b9ca5dfa8d5e912e6b754703f83e64736f6c634300081e0033a264697066735822122074e0033a5890b8801c03002726986741e86eab5032987b4e0f9870b018b50f4764736f6c634300081e0033", -} - -// ExampleDeployerListABI is the input ABI used to generate the binding from. -// Deprecated: Use ExampleDeployerListMetaData.ABI instead. -var ExampleDeployerListABI = ExampleDeployerListMetaData.ABI - -// ExampleDeployerListBin is the compiled bytecode used for deploying new contracts. -// Deprecated: Use ExampleDeployerListMetaData.Bin instead. -var ExampleDeployerListBin = ExampleDeployerListMetaData.Bin - -// DeployExampleDeployerList deploys a new Ethereum contract, binding an instance of ExampleDeployerList to it. -func DeployExampleDeployerList(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *ExampleDeployerList, error) { - parsed, err := ExampleDeployerListMetaData.GetAbi() - if err != nil { - return common.Address{}, nil, nil, err - } - if parsed == nil { - return common.Address{}, nil, nil, errors.New("GetABI returned nil") - } - - address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(ExampleDeployerListBin), backend) - if err != nil { - return common.Address{}, nil, nil, err - } - return address, tx, &ExampleDeployerList{ExampleDeployerListCaller: ExampleDeployerListCaller{contract: contract}, ExampleDeployerListTransactor: ExampleDeployerListTransactor{contract: contract}, ExampleDeployerListFilterer: ExampleDeployerListFilterer{contract: contract}}, nil -} - -// ExampleDeployerList is an auto generated Go binding around an Ethereum contract. -type ExampleDeployerList struct { - ExampleDeployerListCaller // Read-only binding to the contract - ExampleDeployerListTransactor // Write-only binding to the contract - ExampleDeployerListFilterer // Log filterer for contract events -} - -// ExampleDeployerListCaller is an auto generated read-only Go binding around an Ethereum contract. -type ExampleDeployerListCaller struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// ExampleDeployerListTransactor is an auto generated write-only Go binding around an Ethereum contract. -type ExampleDeployerListTransactor struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// ExampleDeployerListFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type ExampleDeployerListFilterer struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// ExampleDeployerListSession is an auto generated Go binding around an Ethereum contract, -// with pre-set call and transact options. -type ExampleDeployerListSession struct { - Contract *ExampleDeployerList // Generic contract binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// ExampleDeployerListCallerSession is an auto generated read-only Go binding around an Ethereum contract, -// with pre-set call options. -type ExampleDeployerListCallerSession struct { - Contract *ExampleDeployerListCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session -} - -// ExampleDeployerListTransactorSession is an auto generated write-only Go binding around an Ethereum contract, -// with pre-set transact options. -type ExampleDeployerListTransactorSession struct { - Contract *ExampleDeployerListTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// ExampleDeployerListRaw is an auto generated low-level Go binding around an Ethereum contract. -type ExampleDeployerListRaw struct { - Contract *ExampleDeployerList // Generic contract binding to access the raw methods on -} - -// ExampleDeployerListCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type ExampleDeployerListCallerRaw struct { - Contract *ExampleDeployerListCaller // Generic read-only contract binding to access the raw methods on -} - -// ExampleDeployerListTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type ExampleDeployerListTransactorRaw struct { - Contract *ExampleDeployerListTransactor // Generic write-only contract binding to access the raw methods on -} - -// NewExampleDeployerList creates a new instance of ExampleDeployerList, bound to a specific deployed contract. -func NewExampleDeployerList(address common.Address, backend bind.ContractBackend) (*ExampleDeployerList, error) { - contract, err := bindExampleDeployerList(address, backend, backend, backend) - if err != nil { - return nil, err - } - return &ExampleDeployerList{ExampleDeployerListCaller: ExampleDeployerListCaller{contract: contract}, ExampleDeployerListTransactor: ExampleDeployerListTransactor{contract: contract}, ExampleDeployerListFilterer: ExampleDeployerListFilterer{contract: contract}}, nil -} - -// NewExampleDeployerListCaller creates a new read-only instance of ExampleDeployerList, bound to a specific deployed contract. -func NewExampleDeployerListCaller(address common.Address, caller bind.ContractCaller) (*ExampleDeployerListCaller, error) { - contract, err := bindExampleDeployerList(address, caller, nil, nil) - if err != nil { - return nil, err - } - return &ExampleDeployerListCaller{contract: contract}, nil -} - -// NewExampleDeployerListTransactor creates a new write-only instance of ExampleDeployerList, bound to a specific deployed contract. -func NewExampleDeployerListTransactor(address common.Address, transactor bind.ContractTransactor) (*ExampleDeployerListTransactor, error) { - contract, err := bindExampleDeployerList(address, nil, transactor, nil) - if err != nil { - return nil, err - } - return &ExampleDeployerListTransactor{contract: contract}, nil -} - -// NewExampleDeployerListFilterer creates a new log filterer instance of ExampleDeployerList, bound to a specific deployed contract. -func NewExampleDeployerListFilterer(address common.Address, filterer bind.ContractFilterer) (*ExampleDeployerListFilterer, error) { - contract, err := bindExampleDeployerList(address, nil, nil, filterer) - if err != nil { - return nil, err - } - return &ExampleDeployerListFilterer{contract: contract}, nil -} - -// bindExampleDeployerList binds a generic wrapper to an already deployed contract. -func bindExampleDeployerList(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := ExampleDeployerListMetaData.GetAbi() - if err != nil { - return nil, err - } - return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_ExampleDeployerList *ExampleDeployerListRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _ExampleDeployerList.Contract.ExampleDeployerListCaller.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_ExampleDeployerList *ExampleDeployerListRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _ExampleDeployerList.Contract.ExampleDeployerListTransactor.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_ExampleDeployerList *ExampleDeployerListRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _ExampleDeployerList.Contract.ExampleDeployerListTransactor.contract.Transact(opts, method, params...) -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_ExampleDeployerList *ExampleDeployerListCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _ExampleDeployerList.Contract.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_ExampleDeployerList *ExampleDeployerListTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _ExampleDeployerList.Contract.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_ExampleDeployerList *ExampleDeployerListTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _ExampleDeployerList.Contract.contract.Transact(opts, method, params...) -} - -// IsAdmin is a free data retrieval call binding the contract method 0x24d7806c. -// -// Solidity: function isAdmin(address addr) view returns(bool) -func (_ExampleDeployerList *ExampleDeployerListCaller) IsAdmin(opts *bind.CallOpts, addr common.Address) (bool, error) { - var out []interface{} - err := _ExampleDeployerList.contract.Call(opts, &out, "isAdmin", addr) - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// IsAdmin is a free data retrieval call binding the contract method 0x24d7806c. -// -// Solidity: function isAdmin(address addr) view returns(bool) -func (_ExampleDeployerList *ExampleDeployerListSession) IsAdmin(addr common.Address) (bool, error) { - return _ExampleDeployerList.Contract.IsAdmin(&_ExampleDeployerList.CallOpts, addr) -} - -// IsAdmin is a free data retrieval call binding the contract method 0x24d7806c. -// -// Solidity: function isAdmin(address addr) view returns(bool) -func (_ExampleDeployerList *ExampleDeployerListCallerSession) IsAdmin(addr common.Address) (bool, error) { - return _ExampleDeployerList.Contract.IsAdmin(&_ExampleDeployerList.CallOpts, addr) -} - -// IsEnabled is a free data retrieval call binding the contract method 0x9015d371. -// -// Solidity: function isEnabled(address addr) view returns(bool) -func (_ExampleDeployerList *ExampleDeployerListCaller) IsEnabled(opts *bind.CallOpts, addr common.Address) (bool, error) { - var out []interface{} - err := _ExampleDeployerList.contract.Call(opts, &out, "isEnabled", addr) - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// IsEnabled is a free data retrieval call binding the contract method 0x9015d371. -// -// Solidity: function isEnabled(address addr) view returns(bool) -func (_ExampleDeployerList *ExampleDeployerListSession) IsEnabled(addr common.Address) (bool, error) { - return _ExampleDeployerList.Contract.IsEnabled(&_ExampleDeployerList.CallOpts, addr) -} - -// IsEnabled is a free data retrieval call binding the contract method 0x9015d371. -// -// Solidity: function isEnabled(address addr) view returns(bool) -func (_ExampleDeployerList *ExampleDeployerListCallerSession) IsEnabled(addr common.Address) (bool, error) { - return _ExampleDeployerList.Contract.IsEnabled(&_ExampleDeployerList.CallOpts, addr) -} - -// IsManager is a free data retrieval call binding the contract method 0xf3ae2415. -// -// Solidity: function isManager(address addr) view returns(bool) -func (_ExampleDeployerList *ExampleDeployerListCaller) IsManager(opts *bind.CallOpts, addr common.Address) (bool, error) { - var out []interface{} - err := _ExampleDeployerList.contract.Call(opts, &out, "isManager", addr) - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// IsManager is a free data retrieval call binding the contract method 0xf3ae2415. -// -// Solidity: function isManager(address addr) view returns(bool) -func (_ExampleDeployerList *ExampleDeployerListSession) IsManager(addr common.Address) (bool, error) { - return _ExampleDeployerList.Contract.IsManager(&_ExampleDeployerList.CallOpts, addr) -} - -// IsManager is a free data retrieval call binding the contract method 0xf3ae2415. -// -// Solidity: function isManager(address addr) view returns(bool) -func (_ExampleDeployerList *ExampleDeployerListCallerSession) IsManager(addr common.Address) (bool, error) { - return _ExampleDeployerList.Contract.IsManager(&_ExampleDeployerList.CallOpts, addr) -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_ExampleDeployerList *ExampleDeployerListCaller) Owner(opts *bind.CallOpts) (common.Address, error) { - var out []interface{} - err := _ExampleDeployerList.contract.Call(opts, &out, "owner") - - if err != nil { - return *new(common.Address), err - } - - out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - - return out0, err - -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_ExampleDeployerList *ExampleDeployerListSession) Owner() (common.Address, error) { - return _ExampleDeployerList.Contract.Owner(&_ExampleDeployerList.CallOpts) -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_ExampleDeployerList *ExampleDeployerListCallerSession) Owner() (common.Address, error) { - return _ExampleDeployerList.Contract.Owner(&_ExampleDeployerList.CallOpts) -} - -// DeployContract is a paid mutator transaction binding the contract method 0x6cd5c39b. -// -// Solidity: function deployContract() returns() -func (_ExampleDeployerList *ExampleDeployerListTransactor) DeployContract(opts *bind.TransactOpts) (*types.Transaction, error) { - return _ExampleDeployerList.contract.Transact(opts, "deployContract") -} - -// DeployContract is a paid mutator transaction binding the contract method 0x6cd5c39b. -// -// Solidity: function deployContract() returns() -func (_ExampleDeployerList *ExampleDeployerListSession) DeployContract() (*types.Transaction, error) { - return _ExampleDeployerList.Contract.DeployContract(&_ExampleDeployerList.TransactOpts) -} - -// DeployContract is a paid mutator transaction binding the contract method 0x6cd5c39b. -// -// Solidity: function deployContract() returns() -func (_ExampleDeployerList *ExampleDeployerListTransactorSession) DeployContract() (*types.Transaction, error) { - return _ExampleDeployerList.Contract.DeployContract(&_ExampleDeployerList.TransactOpts) -} - -// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. -// -// Solidity: function renounceOwnership() returns() -func (_ExampleDeployerList *ExampleDeployerListTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { - return _ExampleDeployerList.contract.Transact(opts, "renounceOwnership") -} - -// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. -// -// Solidity: function renounceOwnership() returns() -func (_ExampleDeployerList *ExampleDeployerListSession) RenounceOwnership() (*types.Transaction, error) { - return _ExampleDeployerList.Contract.RenounceOwnership(&_ExampleDeployerList.TransactOpts) -} - -// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. -// -// Solidity: function renounceOwnership() returns() -func (_ExampleDeployerList *ExampleDeployerListTransactorSession) RenounceOwnership() (*types.Transaction, error) { - return _ExampleDeployerList.Contract.RenounceOwnership(&_ExampleDeployerList.TransactOpts) -} - -// Revoke is a paid mutator transaction binding the contract method 0x74a8f103. -// -// Solidity: function revoke(address addr) returns() -func (_ExampleDeployerList *ExampleDeployerListTransactor) Revoke(opts *bind.TransactOpts, addr common.Address) (*types.Transaction, error) { - return _ExampleDeployerList.contract.Transact(opts, "revoke", addr) -} - -// Revoke is a paid mutator transaction binding the contract method 0x74a8f103. -// -// Solidity: function revoke(address addr) returns() -func (_ExampleDeployerList *ExampleDeployerListSession) Revoke(addr common.Address) (*types.Transaction, error) { - return _ExampleDeployerList.Contract.Revoke(&_ExampleDeployerList.TransactOpts, addr) -} - -// Revoke is a paid mutator transaction binding the contract method 0x74a8f103. -// -// Solidity: function revoke(address addr) returns() -func (_ExampleDeployerList *ExampleDeployerListTransactorSession) Revoke(addr common.Address) (*types.Transaction, error) { - return _ExampleDeployerList.Contract.Revoke(&_ExampleDeployerList.TransactOpts, addr) -} - -// SetAdmin is a paid mutator transaction binding the contract method 0x704b6c02. -// -// Solidity: function setAdmin(address addr) returns() -func (_ExampleDeployerList *ExampleDeployerListTransactor) SetAdmin(opts *bind.TransactOpts, addr common.Address) (*types.Transaction, error) { - return _ExampleDeployerList.contract.Transact(opts, "setAdmin", addr) -} - -// SetAdmin is a paid mutator transaction binding the contract method 0x704b6c02. -// -// Solidity: function setAdmin(address addr) returns() -func (_ExampleDeployerList *ExampleDeployerListSession) SetAdmin(addr common.Address) (*types.Transaction, error) { - return _ExampleDeployerList.Contract.SetAdmin(&_ExampleDeployerList.TransactOpts, addr) -} - -// SetAdmin is a paid mutator transaction binding the contract method 0x704b6c02. -// -// Solidity: function setAdmin(address addr) returns() -func (_ExampleDeployerList *ExampleDeployerListTransactorSession) SetAdmin(addr common.Address) (*types.Transaction, error) { - return _ExampleDeployerList.Contract.SetAdmin(&_ExampleDeployerList.TransactOpts, addr) -} - -// SetEnabled is a paid mutator transaction binding the contract method 0x0aaf7043. -// -// Solidity: function setEnabled(address addr) returns() -func (_ExampleDeployerList *ExampleDeployerListTransactor) SetEnabled(opts *bind.TransactOpts, addr common.Address) (*types.Transaction, error) { - return _ExampleDeployerList.contract.Transact(opts, "setEnabled", addr) -} - -// SetEnabled is a paid mutator transaction binding the contract method 0x0aaf7043. -// -// Solidity: function setEnabled(address addr) returns() -func (_ExampleDeployerList *ExampleDeployerListSession) SetEnabled(addr common.Address) (*types.Transaction, error) { - return _ExampleDeployerList.Contract.SetEnabled(&_ExampleDeployerList.TransactOpts, addr) -} - -// SetEnabled is a paid mutator transaction binding the contract method 0x0aaf7043. -// -// Solidity: function setEnabled(address addr) returns() -func (_ExampleDeployerList *ExampleDeployerListTransactorSession) SetEnabled(addr common.Address) (*types.Transaction, error) { - return _ExampleDeployerList.Contract.SetEnabled(&_ExampleDeployerList.TransactOpts, addr) -} - -// SetManager is a paid mutator transaction binding the contract method 0xd0ebdbe7. -// -// Solidity: function setManager(address addr) returns() -func (_ExampleDeployerList *ExampleDeployerListTransactor) SetManager(opts *bind.TransactOpts, addr common.Address) (*types.Transaction, error) { - return _ExampleDeployerList.contract.Transact(opts, "setManager", addr) -} - -// SetManager is a paid mutator transaction binding the contract method 0xd0ebdbe7. -// -// Solidity: function setManager(address addr) returns() -func (_ExampleDeployerList *ExampleDeployerListSession) SetManager(addr common.Address) (*types.Transaction, error) { - return _ExampleDeployerList.Contract.SetManager(&_ExampleDeployerList.TransactOpts, addr) -} - -// SetManager is a paid mutator transaction binding the contract method 0xd0ebdbe7. -// -// Solidity: function setManager(address addr) returns() -func (_ExampleDeployerList *ExampleDeployerListTransactorSession) SetManager(addr common.Address) (*types.Transaction, error) { - return _ExampleDeployerList.Contract.SetManager(&_ExampleDeployerList.TransactOpts, addr) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address newOwner) returns() -func (_ExampleDeployerList *ExampleDeployerListTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { - return _ExampleDeployerList.contract.Transact(opts, "transferOwnership", newOwner) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address newOwner) returns() -func (_ExampleDeployerList *ExampleDeployerListSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { - return _ExampleDeployerList.Contract.TransferOwnership(&_ExampleDeployerList.TransactOpts, newOwner) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address newOwner) returns() -func (_ExampleDeployerList *ExampleDeployerListTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { - return _ExampleDeployerList.Contract.TransferOwnership(&_ExampleDeployerList.TransactOpts, newOwner) -} - -// ExampleDeployerListOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the ExampleDeployerList contract. -type ExampleDeployerListOwnershipTransferredIterator struct { - Event *ExampleDeployerListOwnershipTransferred // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *ExampleDeployerListOwnershipTransferredIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(ExampleDeployerListOwnershipTransferred) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(ExampleDeployerListOwnershipTransferred) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *ExampleDeployerListOwnershipTransferredIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *ExampleDeployerListOwnershipTransferredIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// ExampleDeployerListOwnershipTransferred represents a OwnershipTransferred event raised by the ExampleDeployerList contract. -type ExampleDeployerListOwnershipTransferred struct { - PreviousOwner common.Address - NewOwner common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) -func (_ExampleDeployerList *ExampleDeployerListFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*ExampleDeployerListOwnershipTransferredIterator, error) { - - var previousOwnerRule []interface{} - for _, previousOwnerItem := range previousOwner { - previousOwnerRule = append(previousOwnerRule, previousOwnerItem) - } - var newOwnerRule []interface{} - for _, newOwnerItem := range newOwner { - newOwnerRule = append(newOwnerRule, newOwnerItem) - } - - logs, sub, err := _ExampleDeployerList.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) - if err != nil { - return nil, err - } - return &ExampleDeployerListOwnershipTransferredIterator{contract: _ExampleDeployerList.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil -} - -// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) -func (_ExampleDeployerList *ExampleDeployerListFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *ExampleDeployerListOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { - - var previousOwnerRule []interface{} - for _, previousOwnerItem := range previousOwner { - previousOwnerRule = append(previousOwnerRule, previousOwnerItem) - } - var newOwnerRule []interface{} - for _, newOwnerItem := range newOwner { - newOwnerRule = append(newOwnerRule, newOwnerItem) - } - - logs, sub, err := _ExampleDeployerList.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(ExampleDeployerListOwnershipTransferred) - if err := _ExampleDeployerList.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) -func (_ExampleDeployerList *ExampleDeployerListFilterer) ParseOwnershipTransferred(log types.Log) (*ExampleDeployerListOwnershipTransferred, error) { - event := new(ExampleDeployerListOwnershipTransferred) - if err := _ExampleDeployerList.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} diff --git a/contracts/contracts/ERC20NativeMinter.sol b/contracts/contracts/ERC20NativeMinter.sol deleted file mode 100644 index 34fb231fc9..0000000000 --- a/contracts/contracts/ERC20NativeMinter.sol +++ /dev/null @@ -1,59 +0,0 @@ -//SPDX-License-Identifier: MIT -pragma solidity ^0.8.24; - -import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; -import "./AllowList.sol"; -import "./interfaces/INativeMinter.sol"; - -// Precompiled Native Minter Contract Address -address constant MINTER_ADDRESS = 0x0200000000000000000000000000000000000001; -// Designated Blackhole Address -address constant BLACKHOLE_ADDRESS = 0x0100000000000000000000000000000000000000; - -contract ERC20NativeMinter is ERC20, AllowList { - string private constant TOKEN_NAME = "ERC20NativeMinterToken"; - string private constant TOKEN_SYMBOL = "XMPL"; - - INativeMinter nativeMinter = INativeMinter(MINTER_ADDRESS); - - event Deposit(address indexed dst, uint256 wad); - event Mintdrawal(address indexed src, uint256 wad); - - constructor(uint256 initSupply) ERC20(TOKEN_NAME, TOKEN_SYMBOL) AllowList(MINTER_ADDRESS) { - // Mints INIT_SUPPLY to owner - _mint(_msgSender(), initSupply); - } - - // Mints [amount] number of ERC20 token to [to] address. - function mint(address to, uint256 amount) external onlyOwner { - _mint(to, amount); - } - - // Burns [amount] number of ERC20 token from [from] address. - function burn(address from, uint256 amount) external onlyOwner { - _burn(from, amount); - } - - // Swaps [amount] number of ERC20 token for native coin. - function mintdraw(uint256 wad) external { - // Burn ERC20 token first. - _burn(_msgSender(), wad); - // Mints [amount] number of native coins (gas coin) to [msg.sender] address. - // Calls NativeMinter precompile through INativeMinter interface. - nativeMinter.mintNativeCoin(_msgSender(), wad); - emit Mintdrawal(_msgSender(), wad); - } - - // Swaps [amount] number of native gas coins for ERC20 tokens. - function deposit() external payable { - // Burn native token by sending to BLACKHOLE_ADDRESS - payable(BLACKHOLE_ADDRESS).transfer(msg.value); - // Mint ERC20 token. - _mint(_msgSender(), msg.value); - emit Deposit(_msgSender(), msg.value); - } - - function decimals() public view virtual override returns (uint8) { - return 18; - } -} diff --git a/contracts/contracts/compile.go b/contracts/contracts/compile.go deleted file mode 100644 index 8740787fbf..0000000000 --- a/contracts/contracts/compile.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package contracts - -// Step 1: Compile Solidity contracts to generate ABI and bin files -//go:generate solc-v0.8.30 --evm-version cancun -o ../artifacts --overwrite --abi --bin --base-path . @openzeppelin/contracts/=../node_modules/@openzeppelin/contracts/ AllowList.sol ERC20NativeMinter.sol ExampleFeeManager.sol ExampleRewardManager.sol ExampleTxAllowList.sol ExampleWarp.sol - -// Step 2: Generate Go bindings from the compiled artifacts -//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type AllowList --abi ../artifacts/AllowList.abi --bin ../artifacts/AllowList.bin --out ../bindings/gen_allowlist.go -//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type ERC20NativeMinter --abi ../artifacts/ERC20NativeMinter.abi --bin ../artifacts/ERC20NativeMinter.bin --out ../bindings/gen_erc20nativeminter.go -//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type ExampleFeeManager --abi ../artifacts/ExampleFeeManager.abi --bin ../artifacts/ExampleFeeManager.bin --out ../bindings/gen_examplefeemanager.go -//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type ExampleRewardManager --abi ../artifacts/ExampleRewardManager.abi --bin ../artifacts/ExampleRewardManager.bin --out ../bindings/gen_examplerewardmanager.go -//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type ExampleTxAllowList --abi ../artifacts/ExampleTxAllowList.abi --bin ../artifacts/ExampleTxAllowList.bin --out ../bindings/gen_exampletxallowlist.go -//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type ExampleWarp --abi ../artifacts/ExampleWarp.abi --bin ../artifacts/ExampleWarp.bin --out ../bindings/gen_examplewarp.go diff --git a/contracts/contracts/test/ERC20NativeMinterTest.sol b/contracts/contracts/test/ERC20NativeMinterTest.sol deleted file mode 100644 index d8d41b1af0..0000000000 --- a/contracts/contracts/test/ERC20NativeMinterTest.sol +++ /dev/null @@ -1,144 +0,0 @@ -//SPDX-License-Identifier: MIT -pragma solidity ^0.8.24; - -import "../ERC20NativeMinter.sol"; -import "../interfaces/INativeMinter.sol"; -import "./AllowListTest.sol"; - -// TODO: -// this contract adds another (unwanted) layer of indirection -// but it's the easiest way to match the previous HardHat testing functionality. -// Once we completely migrate to DS-test, we can simplify this set of tests. -contract Minter { - ERC20NativeMinter token; - - constructor(address tokenAddress) { - token = ERC20NativeMinter(tokenAddress); - } - - function mintdraw(uint amount) external { - token.mintdraw(amount); - } - - function deposit(uint value) external { - token.deposit{value: value}(); - } -} - -contract ERC20NativeMinterTest is AllowListTest { - INativeMinter nativeMinter = INativeMinter(MINTER_ADDRESS); - - function setUp() public { - // noop - } - - function step_mintdrawFailure() public { - ERC20NativeMinter token = new ERC20NativeMinter(1000); - address tokenAddress = address(token); - - assertRole(nativeMinter.readAllowList(tokenAddress), AllowList.Role.None); - - try token.mintdraw(100) { - assertTrue(false, "mintdraw should fail"); - } catch {} // TODO should match on an error to make sure that this is failing in the way that's expected - } - - function step_addMinter() public { - ERC20NativeMinter token = new ERC20NativeMinter(1000); - address tokenAddress = address(token); - - assertRole(nativeMinter.readAllowList(tokenAddress), AllowList.Role.None); - - nativeMinter.setEnabled(tokenAddress); - - assertRole(nativeMinter.readAllowList(tokenAddress), AllowList.Role.Enabled); - } - - function step_adminMintdraw() public { - ERC20NativeMinter token = new ERC20NativeMinter(1000); - address tokenAddress = address(token); - - address testAddress = address(this); - - nativeMinter.setEnabled(tokenAddress); - - uint initialTokenBalance = token.balanceOf(testAddress); - uint initialNativeBalance = testAddress.balance; - - uint amount = 100; - - token.mintdraw(amount); - - assertEq(token.balanceOf(testAddress), initialTokenBalance - amount); - assertEq(testAddress.balance, initialNativeBalance + amount); - } - - function step_minterMintdrawFailure() public { - ERC20NativeMinter token = new ERC20NativeMinter(1000); - address tokenAddress = address(token); - - Minter minter = new Minter(tokenAddress); - address minterAddress = address(minter); - - nativeMinter.setEnabled(tokenAddress); - - uint initialTokenBalance = token.balanceOf(minterAddress); - uint initialNativeBalance = minterAddress.balance; - - assertEq(initialTokenBalance, 0); - - try minter.mintdraw(100) { - assertTrue(false, "mintdraw should fail"); - } catch {} // TODO should match on an error to make sure that this is failing in the way that's expected - - assertEq(token.balanceOf(minterAddress), initialTokenBalance); - assertEq(minterAddress.balance, initialNativeBalance); - } - - function step_minterDeposit() public { - ERC20NativeMinter token = new ERC20NativeMinter(1000); - address tokenAddress = address(token); - - Minter minter = new Minter(tokenAddress); - address minterAddress = address(minter); - - nativeMinter.setEnabled(tokenAddress); - - uint amount = 100; - - nativeMinter.mintNativeCoin(minterAddress, amount); - - uint initialTokenBalance = token.balanceOf(minterAddress); - uint initialNativeBalance = minterAddress.balance; - - minter.deposit(amount); - - assertEq(token.balanceOf(minterAddress), initialTokenBalance + amount); - assertEq(minterAddress.balance, initialNativeBalance - amount); - } - - function step_mintdraw() public { - ERC20NativeMinter token = new ERC20NativeMinter(1000); - address tokenAddress = address(token); - - Minter minter = new Minter(tokenAddress); - address minterAddress = address(minter); - - nativeMinter.setEnabled(tokenAddress); - - uint amount = 100; - - uint initialNativeBalance = minterAddress.balance; - assertEq(initialNativeBalance, 0); - - token.mint(minterAddress, amount); - - uint initialTokenBalance = token.balanceOf(minterAddress); - assertEq(initialTokenBalance, amount); - - minter.mintdraw(amount); - - assertEq(token.balanceOf(minterAddress), 0); - assertEq(minterAddress.balance, amount); - } -} diff --git a/contracts/lib/openzeppelin-contracts b/contracts/lib/openzeppelin-contracts deleted file mode 160000 index c64a1edb67..0000000000 --- a/contracts/lib/openzeppelin-contracts +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c64a1edb67b6e3f4a15cca8909c9482ad33a02b0 diff --git a/contracts/scripts/deployERC20NativeMinter.ts b/contracts/scripts/deployERC20NativeMinter.ts deleted file mode 100644 index 9ca2461726..0000000000 --- a/contracts/scripts/deployERC20NativeMinter.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { ethers } from "hardhat" -import { ERC20NativeMinter } from "typechain-types" - -const main = async (): Promise => { - const token: ERC20NativeMinter = await ethers.deployContract("ERC20NativeMinter") - await token.waitForDeployment() - console.log(`Token deployed to: ${token.target}`) -} - -main() - .then(() => process.exit(0)) - .catch(error => { - console.error(error) - process.exit(1) - }) diff --git a/contracts/test/README.md b/contracts/test/README.md deleted file mode 100644 index 2983ba29d3..0000000000 --- a/contracts/test/README.md +++ /dev/null @@ -1,64 +0,0 @@ -# Testing Precompiles - -If you can, put all of your test logic into DS-test tests. Prefix test functions with `step_`. There's also a `setUp` function that gets called before the test contract is deployed. The current best-practice is to re-deploy one test contract per `test` function called in `*.ts` test definitions. The `setUp` method should be called once, then `step_` functions passed in as the 2nd argument to `test("", )` will be called in order. `test.only` and `test.skip` behave the same way as `it.only` and `it.skip`. There's also a `test.debug` that combines `test.only` with some extra event logging (you can use `emit log_string` to help debug Solidity test code). - -The `test` function is a wrapper around Mocha's `it` function. It provides a normalized framework for running the -majority of your test assertions inside of a smart-contract, using `DS-Test`. -The API can be used as follows (all of the examples are equivalent): - -```ts -test("", ""); - -test("", [""]); - -test("", { - method: "", - overrides: {}, - shouldFail: false, - debug: false, -}); - -test("", [ - { - method: "", - overrides: {}, - shouldFail: false, - debug: false, - }, -]); - -test( - "", - [{ method: "", shouldFail: false, debug: false }], - {} -); -``` - -Many contract functions can be called as a part of the same test: - -```ts -test("", ["", "", ""]) -``` - -Individual test functions can describe their own overrides with the `overrides` property. -If an object is passed in as the third argument to `test`, it will be used as the default overrides for all test -functions. -The following are equivalent: - -```ts -test("", [ - { method: "", overrides: { from: "0x123" } }, -]); - -test("", [{ method: "" }], { - from: "0x123", -}); -``` - -In the above cases, the `from` override must be a signer. -The `shouldFail` property can be used to indicate that the test function should fail. This should be used sparingly -as it is not possible to match on the failure reason. -Furthermore, the `debug` property can be used to print any thrown errors when attempting to -send a transaction or while waiting for the transaction to be confirmed (the transaction is the smart contract call). -`debug` will also cause any parseable event logs to be printed that start with the `log_` prefix. -`DSTest` contracts have several options for emitting `log_` events. diff --git a/contracts/test/contract_native_minter.ts b/contracts/test/contract_native_minter.ts deleted file mode 100644 index 076b7552ab..0000000000 --- a/contracts/test/contract_native_minter.ts +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -import { ethers } from "hardhat" -import { test } from "./utils" -import { expect } from "chai"; -import { Contract, Signer } from "ethers" -import { INativeMinter } from "typechain-types"; - -const ADMIN_ADDRESS: string = "0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC" -const MINT_PRECOMPILE_ADDRESS = "0x0200000000000000000000000000000000000001" - -describe("ERC20NativeMinter", function () { - beforeEach('Setup DS-Test contract', async function () { - const signer = await ethers.getSigner(ADMIN_ADDRESS) - const nativeMinterPromise = ethers.getContractAt("INativeMinter", MINT_PRECOMPILE_ADDRESS, signer) - - return ethers.getContractFactory("ERC20NativeMinterTest", { signer }) - .then(factory => factory.deploy()) - .then(contract => { - this.testContract = contract - return contract.waitForDeployment().then(() => contract) - }) - .then(contract => contract.setUp()) - .then(tx => Promise.all([nativeMinterPromise, tx.wait()])) - .then(([nativeMinter]) => nativeMinter.setAdmin(this.testContract.target)) - .then(tx => tx.wait()) - }) - - test("contract should not be able to mintdraw", "step_mintdrawFailure") - - test("should be added to minter list", "step_addMinter") - - test("admin should mintdraw", "step_adminMintdraw") - - test("minter should not mintdraw", "step_minterMintdrawFailure") - - test("should deposit for minter", "step_minterDeposit") - - test("minter should mintdraw", "step_mintdraw") -}) - - -describe("INativeMinter", function () { - let owner: Signer - let ownerAddress: string - let contract: INativeMinter - before(async function () { - owner = await ethers.getSigner(ADMIN_ADDRESS); - ownerAddress = await owner.getAddress() - contract = await ethers.getContractAt("INativeMinter", MINT_PRECOMPILE_ADDRESS, owner) - }); - - it("should emit NativeCoinMinted event", async function () { - let testAddress = "0x0444400000000000000000000000000000000004" - let amount = 1000 - let tx = await contract.mintNativeCoin(testAddress, amount) - let receipt = await tx.wait() - await expect(receipt) - .to.emit(contract, 'NativeCoinMinted') - .withArgs(ownerAddress, testAddress, amount) - }) -}) diff --git a/precompile/.gitignore b/precompile/.gitignore index d4f588edfe..c75d83d135 100644 --- a/precompile/.gitignore +++ b/precompile/.gitignore @@ -1 +1,3 @@ -artifacts/ +**/artifacts/ +**/artifacts/*.abi +**/artifacts/*.bin diff --git a/precompile/allowlist/allowlisttest/allowlist_test.go b/precompile/allowlist/allowlist_test.go similarity index 91% rename from precompile/allowlist/allowlisttest/allowlist_test.go rename to precompile/allowlist/allowlist_test.go index 1caad6053b..0c7bd19950 100644 --- a/precompile/allowlist/allowlisttest/allowlist_test.go +++ b/precompile/allowlist/allowlist_test.go @@ -1,7 +1,7 @@ // Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package allowlisttest +package allowlist_test import ( "testing" @@ -9,6 +9,7 @@ import ( "github.com/ava-labs/libevm/common" "github.com/ava-labs/subnet-evm/precompile/allowlist" + "github.com/ava-labs/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/subnet-evm/precompile/contract" "github.com/ava-labs/subnet-evm/precompile/modules" "github.com/ava-labs/subnet-evm/precompile/precompileconfig" @@ -63,5 +64,5 @@ func TestAllowListRun(t *testing.T) { Configurator: &dummyConfigurator{}, ConfigKey: "dummy", } - RunPrecompileWithAllowListTests(t, dummyModule, nil) + allowlisttest.RunPrecompileWithAllowListTests(t, dummyModule, nil) } diff --git a/precompile/allowlist/allowlisttest/AllowList.sol b/precompile/allowlist/allowlisttest/bindings/AllowList.sol similarity index 97% rename from precompile/allowlist/allowlisttest/AllowList.sol rename to precompile/allowlist/allowlisttest/bindings/AllowList.sol index 390c64b915..f3eb1c84c3 100644 --- a/precompile/allowlist/allowlisttest/AllowList.sol +++ b/precompile/allowlist/allowlisttest/bindings/AllowList.sol @@ -1,7 +1,7 @@ //SPDX-License-Identifier: MIT pragma solidity ^0.8.24; -import "precompile/allowlist/allowlisttest/IAllowList.sol"; +import "./IAllowList.sol"; // AllowList is a base contract to use AllowList precompile capabilities. contract AllowList { diff --git a/precompile/allowlist/allowlisttest/AllowListTest.sol b/precompile/allowlist/allowlisttest/bindings/AllowListTest.sol similarity index 76% rename from precompile/allowlist/allowlisttest/AllowListTest.sol rename to precompile/allowlist/allowlisttest/bindings/AllowListTest.sol index f71a434069..c872192ffd 100644 --- a/precompile/allowlist/allowlisttest/AllowListTest.sol +++ b/precompile/allowlist/allowlisttest/bindings/AllowListTest.sol @@ -1,8 +1,8 @@ //SPDX-License-Identifier: MIT pragma solidity ^0.8.24; -import "precompile/allowlist/allowlisttest/IAllowList.sol"; -import "precompile/allowlist/allowlisttest/AllowList.sol"; +import "./IAllowList.sol"; +import "./AllowList.sol"; contract AllowListTest is AllowList { // Precompiled Allow List Contract Address diff --git a/precompile/allowlist/allowlisttest/IAllowList.sol b/precompile/allowlist/allowlisttest/bindings/IAllowList.sol similarity index 100% rename from precompile/allowlist/allowlisttest/IAllowList.sol rename to precompile/allowlist/allowlisttest/bindings/IAllowList.sol diff --git a/precompile/allowlist/allowlisttest/compile.go b/precompile/allowlist/allowlisttest/bindings/compile.go similarity index 65% rename from precompile/allowlist/allowlisttest/compile.go rename to precompile/allowlist/allowlisttest/bindings/compile.go index 90c76c8c0d..abdadb4e86 100644 --- a/precompile/allowlist/allowlisttest/compile.go +++ b/precompile/allowlist/allowlisttest/bindings/compile.go @@ -1,12 +1,12 @@ // Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package allowlisttest +package bindings // Step 1: Compile Solidity contracts to generate ABI and bin files -//go:generate solc-v0.8.30 --evm-version cancun -o artifacts --overwrite --abi --bin --base-path . precompile/=../../ AllowListTest.sol +//go:generate solc-v0.8.30 -o artifacts --overwrite --abi --bin --base-path . precompile/=../../ --evm-version cancun AllowListTest.sol // Step 2: Generate Go bindings from the compiled artifacts -//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg allowlisttest --type IAllowList --abi artifacts/IAllowList.abi --bin artifacts/IAllowList.bin --out gen_allowlist_binding.go -//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg allowlisttest --type AllowListTest --abi artifacts/AllowListTest.abi --bin artifacts/AllowListTest.bin --out gen_allowlisttest_binding.go +//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type IAllowList --abi artifacts/IAllowList.abi --bin artifacts/IAllowList.bin --out gen_allowlist_binding.go +//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type AllowListTest --abi artifacts/AllowListTest.abi --bin artifacts/AllowListTest.bin --out gen_allowlisttest_binding.go // Step 3: Replace import paths in generated binding to use subnet-evm instead of libevm //go:generate sh -c "sed -i.bak -e 's|github.com/ava-labs/libevm/accounts/abi|github.com/ava-labs/subnet-evm/accounts/abi|g' -e 's|github.com/ava-labs/libevm/accounts/abi/bind|github.com/ava-labs/subnet-evm/accounts/abi/bind|g' gen_allowlist_binding.go gen_allowlisttest_binding.go && rm -f gen_allowlist_binding.go.bak gen_allowlisttest_binding.go.bak" diff --git a/precompile/allowlist/allowlisttest/gen_allowlist_binding.go b/precompile/allowlist/allowlisttest/bindings/gen_allowlist_binding.go similarity index 99% rename from precompile/allowlist/allowlisttest/gen_allowlist_binding.go rename to precompile/allowlist/allowlisttest/bindings/gen_allowlist_binding.go index 7b09e6358b..7f318a0c07 100644 --- a/precompile/allowlist/allowlisttest/gen_allowlist_binding.go +++ b/precompile/allowlist/allowlisttest/bindings/gen_allowlist_binding.go @@ -1,7 +1,7 @@ // Code generated - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package allowlisttest +package bindings import ( "errors" diff --git a/precompile/allowlist/allowlisttest/gen_allowlisttest_binding.go b/precompile/allowlist/allowlisttest/bindings/gen_allowlisttest_binding.go similarity index 99% rename from precompile/allowlist/allowlisttest/gen_allowlisttest_binding.go rename to precompile/allowlist/allowlisttest/bindings/gen_allowlisttest_binding.go index d04a3aeccb..4ce13be5dd 100644 --- a/precompile/allowlist/allowlisttest/gen_allowlisttest_binding.go +++ b/precompile/allowlist/allowlisttest/bindings/gen_allowlisttest_binding.go @@ -1,7 +1,7 @@ // Code generated - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package allowlisttest +package bindings import ( "errors" @@ -32,7 +32,7 @@ var ( // AllowListTestMetaData contains all meta data concerning the AllowListTest contract. var AllowListTestMetaData = &bind.MetaData{ ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"precompileAddr\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"deployContract\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"isAdmin\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"isEnabled\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"isManager\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"revoke\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setEnabled\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x608060405234801561000f575f5ffd5b50604051610ba1380380610ba1833981810160405281019061003191906100d6565b80805f5f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050610101565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100a58261007c565b9050919050565b6100b58161009b565b81146100bf575f5ffd5b50565b5f815190506100d0816100ac565b92915050565b5f602082840312156100eb576100ea610078565b5b5f6100f8848285016100c2565b91505092915050565b610a938061010e5f395ff3fe608060405234801561000f575f5ffd5b5060043610610086575f3560e01c806374a8f1031161005957806374a8f103146100fc5780639015d37114610118578063d0ebdbe714610148578063f3ae24151461016457610086565b80630aaf70431461008a57806324d7806c146100a65780636cd5c39b146100d6578063704b6c02146100e0575b5f5ffd5b6100a4600480360381019061009f9190610841565b610194565b005b6100c060048036038101906100bb9190610841565b6101f8565b6040516100cd9190610886565b60405180910390f35b6100de6102a0565b005b6100fa60048036038101906100f59190610841565b6102c9565b005b61011660048036038101906101119190610841565b61032d565b005b610132600480360381019061012d9190610841565b610391565b60405161013f9190610886565b60405180910390f35b610162600480360381019061015d9190610841565b610439565b005b61017e60048036038101906101799190610841565b61049d565b60405161018b9190610886565b60405180910390f35b61019d336101f8565b806101ad57506101ac3361049d565b5b6101ec576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101e3906108f9565b60405180910390fd5b6101f581610545565b50565b5f5f5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663eb54dae1846040518263ffffffff1660e01b81526004016102539190610926565b602060405180830381865afa15801561026e573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102929190610972565b905060028114915050919050565b6040516102ac906107d7565b604051809103905ff0801580156102c5573d5f5f3e3d5ffd5b5050565b6102d2336101f8565b806102e257506102e13361049d565b5b610321576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610318906108f9565b60405180910390fd5b61032a816105ce565b50565b610336336101f8565b8061034657506103453361049d565b5b610385576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161037c906108f9565b60405180910390fd5b61038e81610657565b50565b5f5f5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663eb54dae1846040518263ffffffff1660e01b81526004016103ec9190610926565b602060405180830381865afa158015610407573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061042b9190610972565b90505f811415915050919050565b610442336101f8565b8061045257506104513361049d565b5b610491576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610488906108f9565b60405180910390fd5b61049a8161074e565b50565b5f5f5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663eb54dae1846040518263ffffffff1660e01b81526004016104f89190610926565b602060405180830381865afa158015610513573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105379190610972565b905060038114915050919050565b5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630aaf7043826040518263ffffffff1660e01b815260040161059e9190610926565b5f604051808303815f87803b1580156105b5575f5ffd5b505af11580156105c7573d5f5f3e3d5ffd5b5050505050565b5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663704b6c02826040518263ffffffff1660e01b81526004016106279190610926565b5f604051808303815f87803b15801561063e575f5ffd5b505af1158015610650573d5f5f3e3d5ffd5b5050505050565b8073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16036106c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106bc906109e7565b60405180910390fd5b5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638c6bfb3b826040518263ffffffff1660e01b815260040161071e9190610926565b5f604051808303815f87803b158015610735575f5ffd5b505af1158015610747573d5f5f3e3d5ffd5b5050505050565b5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d0ebdbe7826040518263ffffffff1660e01b81526004016107a79190610926565b5f604051808303815f87803b1580156107be575f5ffd5b505af11580156107d0573d5f5f3e3d5ffd5b5050505050565b605880610a0683390190565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610810826107e7565b9050919050565b61082081610806565b811461082a575f5ffd5b50565b5f8135905061083b81610817565b92915050565b5f60208284031215610856576108556107e3565b5b5f6108638482850161082d565b91505092915050565b5f8115159050919050565b6108808161086c565b82525050565b5f6020820190506108995f830184610877565b92915050565b5f82825260208201905092915050565b7f63616e6e6f74206d6f6469667920616c6c6f77206c69737400000000000000005f82015250565b5f6108e360188361089f565b91506108ee826108af565b602082019050919050565b5f6020820190508181035f830152610910816108d7565b9050919050565b61092081610806565b82525050565b5f6020820190506109395f830184610917565b92915050565b5f819050919050565b6109518161093f565b811461095b575f5ffd5b50565b5f8151905061096c81610948565b92915050565b5f60208284031215610987576109866107e3565b5b5f6109948482850161095e565b91505092915050565b7f63616e6e6f74207265766f6b65206f776e20726f6c65000000000000000000005f82015250565b5f6109d160168361089f565b91506109dc8261099d565b602082019050919050565b5f6020820190508181035f8301526109fe816109c5565b905091905056fe6080604052348015600e575f5ffd5b50603e80601a5f395ff3fe60806040525f5ffdfea2646970667358221220a7fd128b9a336b66a3348312ffff683afec3d2463be8afea0002908dedbe91ef64736f6c634300081e0033a2646970667358221220aac5e8f0e5089c497ce344ed15cc12bad3f0e306afc1197e4a614731d41e2a5a64736f6c634300081e0033", + Bin: "0x608060405234801561000f575f5ffd5b50604051610ba1380380610ba1833981810160405281019061003191906100d6565b80805f5f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050610101565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100a58261007c565b9050919050565b6100b58161009b565b81146100bf575f5ffd5b50565b5f815190506100d0816100ac565b92915050565b5f602082840312156100eb576100ea610078565b5b5f6100f8848285016100c2565b91505092915050565b610a938061010e5f395ff3fe608060405234801561000f575f5ffd5b5060043610610086575f3560e01c806374a8f1031161005957806374a8f103146100fc5780639015d37114610118578063d0ebdbe714610148578063f3ae24151461016457610086565b80630aaf70431461008a57806324d7806c146100a65780636cd5c39b146100d6578063704b6c02146100e0575b5f5ffd5b6100a4600480360381019061009f9190610841565b610194565b005b6100c060048036038101906100bb9190610841565b6101f8565b6040516100cd9190610886565b60405180910390f35b6100de6102a0565b005b6100fa60048036038101906100f59190610841565b6102c9565b005b61011660048036038101906101119190610841565b61032d565b005b610132600480360381019061012d9190610841565b610391565b60405161013f9190610886565b60405180910390f35b610162600480360381019061015d9190610841565b610439565b005b61017e60048036038101906101799190610841565b61049d565b60405161018b9190610886565b60405180910390f35b61019d336101f8565b806101ad57506101ac3361049d565b5b6101ec576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101e3906108f9565b60405180910390fd5b6101f581610545565b50565b5f5f5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663eb54dae1846040518263ffffffff1660e01b81526004016102539190610926565b602060405180830381865afa15801561026e573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102929190610972565b905060028114915050919050565b6040516102ac906107d7565b604051809103905ff0801580156102c5573d5f5f3e3d5ffd5b5050565b6102d2336101f8565b806102e257506102e13361049d565b5b610321576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610318906108f9565b60405180910390fd5b61032a816105ce565b50565b610336336101f8565b8061034657506103453361049d565b5b610385576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161037c906108f9565b60405180910390fd5b61038e81610657565b50565b5f5f5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663eb54dae1846040518263ffffffff1660e01b81526004016103ec9190610926565b602060405180830381865afa158015610407573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061042b9190610972565b90505f811415915050919050565b610442336101f8565b8061045257506104513361049d565b5b610491576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610488906108f9565b60405180910390fd5b61049a8161074e565b50565b5f5f5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663eb54dae1846040518263ffffffff1660e01b81526004016104f89190610926565b602060405180830381865afa158015610513573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105379190610972565b905060038114915050919050565b5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630aaf7043826040518263ffffffff1660e01b815260040161059e9190610926565b5f604051808303815f87803b1580156105b5575f5ffd5b505af11580156105c7573d5f5f3e3d5ffd5b5050505050565b5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663704b6c02826040518263ffffffff1660e01b81526004016106279190610926565b5f604051808303815f87803b15801561063e575f5ffd5b505af1158015610650573d5f5f3e3d5ffd5b5050505050565b8073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16036106c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106bc906109e7565b60405180910390fd5b5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638c6bfb3b826040518263ffffffff1660e01b815260040161071e9190610926565b5f604051808303815f87803b158015610735575f5ffd5b505af1158015610747573d5f5f3e3d5ffd5b5050505050565b5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d0ebdbe7826040518263ffffffff1660e01b81526004016107a79190610926565b5f604051808303815f87803b1580156107be575f5ffd5b505af11580156107d0573d5f5f3e3d5ffd5b5050505050565b605880610a0683390190565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610810826107e7565b9050919050565b61082081610806565b811461082a575f5ffd5b50565b5f8135905061083b81610817565b92915050565b5f60208284031215610856576108556107e3565b5b5f6108638482850161082d565b91505092915050565b5f8115159050919050565b6108808161086c565b82525050565b5f6020820190506108995f830184610877565b92915050565b5f82825260208201905092915050565b7f63616e6e6f74206d6f6469667920616c6c6f77206c69737400000000000000005f82015250565b5f6108e360188361089f565b91506108ee826108af565b602082019050919050565b5f6020820190508181035f830152610910816108d7565b9050919050565b61092081610806565b82525050565b5f6020820190506109395f830184610917565b92915050565b5f819050919050565b6109518161093f565b811461095b575f5ffd5b50565b5f8151905061096c81610948565b92915050565b5f60208284031215610987576109866107e3565b5b5f6109948482850161095e565b91505092915050565b7f63616e6e6f74207265766f6b65206f776e20726f6c65000000000000000000005f82015250565b5f6109d160168361089f565b91506109dc8261099d565b602082019050919050565b5f6020820190508181035f8301526109fe816109c5565b905091905056fe6080604052348015600e575f5ffd5b50603e80601a5f395ff3fe60806040525f5ffdfea2646970667358221220a6f35569427acc58ad5367cdacdafc7cbf00ed36744b876fba3bd8433689c4a564736f6c634300081e0033a2646970667358221220b9610a9e66cd5a3a7c0ccc575d7228dff9f3846ffc78cf4eccd34dd152f9297664736f6c634300081e0033", } // AllowListTestABI is the input ABI used to generate the binding from. diff --git a/precompile/allowlist/allowlisttest/test_allowlist_helpers.go b/precompile/allowlist/allowlisttest/test_allowlist_helpers.go new file mode 100644 index 0000000000..f9e5891e07 --- /dev/null +++ b/precompile/allowlist/allowlisttest/test_allowlist_helpers.go @@ -0,0 +1,70 @@ +// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +package allowlisttest + +import ( + "math/big" + "testing" + + "github.com/ava-labs/libevm/common" + "github.com/ava-labs/libevm/core/types" + "github.com/stretchr/testify/require" + + "github.com/ava-labs/subnet-evm/accounts/abi/bind" + "github.com/ava-labs/subnet-evm/precompile/allowlist" + "github.com/ava-labs/subnet-evm/precompile/contracts/testutils" + + sim "github.com/ava-labs/subnet-evm/ethclient/simulated" +) + +// All precompiles that use the AllowList pattern extend IAllowList in Solidity, so their Go bindings +// will automatically have these 5 methods and implement the AllowListContract interface. +// Defining this interface allows the helper functions to work with any precompile that uses the AllowList pattern. +type AllowListContract interface { + ReadAllowList(opts *bind.CallOpts, addr common.Address) (*big.Int, error) + SetEnabled(opts *bind.TransactOpts, addr common.Address) (*types.Transaction, error) + SetAdmin(opts *bind.TransactOpts, addr common.Address) (*types.Transaction, error) + SetManager(opts *bind.TransactOpts, addr common.Address) (*types.Transaction, error) + SetNone(opts *bind.TransactOpts, addr common.Address) (*types.Transaction, error) +} + +// VerifyRole checks that the given address has the expected role in the allow list. +func VerifyRole(t *testing.T, contract AllowListContract, address common.Address, expectedRole allowlist.Role) { + t.Helper() + role, err := contract.ReadAllowList(nil, address) + require.NoError(t, err) + require.Equal(t, expectedRole.Big(), role) +} + +// SetAsEnabled sets the given address as Enabled in the allow list. +func SetAsEnabled(t *testing.T, b *sim.Backend, contract AllowListContract, auth *bind.TransactOpts, address common.Address) { + t.Helper() + tx, err := contract.SetEnabled(auth, address) + require.NoError(t, err) + testutils.WaitReceiptSuccessful(t, b, tx) +} + +// SetAsAdmin sets the given address as Admin in the allow list. +func SetAsAdmin(t *testing.T, b *sim.Backend, contract AllowListContract, auth *bind.TransactOpts, address common.Address) { + t.Helper() + tx, err := contract.SetAdmin(auth, address) + require.NoError(t, err) + testutils.WaitReceiptSuccessful(t, b, tx) +} + +// SetAsManager sets the given address as Manager in the allow list. +func SetAsManager(t *testing.T, b *sim.Backend, contract AllowListContract, auth *bind.TransactOpts, address common.Address) { + t.Helper() + tx, err := contract.SetManager(auth, address) + require.NoError(t, err) + testutils.WaitReceiptSuccessful(t, b, tx) +} + +// SetAsNone revokes the role of the given address in the allow list. +func SetAsNone(t *testing.T, b *sim.Backend, contract AllowListContract, auth *bind.TransactOpts, address common.Address) { + t.Helper() + tx, err := contract.SetNone(auth, address) + require.NoError(t, err) + testutils.WaitReceiptSuccessful(t, b, tx) +} diff --git a/precompile/allowlist/allowlisttest/config_test.go b/precompile/allowlist/config_test.go similarity index 69% rename from precompile/allowlist/allowlisttest/config_test.go rename to precompile/allowlist/config_test.go index 544ead9de1..29a057f9e8 100644 --- a/precompile/allowlist/allowlisttest/config_test.go +++ b/precompile/allowlist/config_test.go @@ -1,12 +1,13 @@ // Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package allowlisttest +package allowlist_test import ( "testing" "github.com/ava-labs/subnet-evm/precompile/allowlist" + "github.com/ava-labs/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/subnet-evm/precompile/modules" ) @@ -18,9 +19,9 @@ var testModule = modules.Module{ } func TestVerifyAllowlist(t *testing.T) { - RunPrecompileWithAllowListTests(t, testModule, nil) + allowlisttest.RunPrecompileWithAllowListTests(t, testModule, nil) } func TestEqualAllowList(t *testing.T) { - EqualPrecompileWithAllowListTests(t, testModule, nil) + allowlisttest.EqualPrecompileWithAllowListTests(t, testModule, nil) } diff --git a/precompile/contracts/deployerallowlist/deployerallowlisttest/config_test.go b/precompile/contracts/deployerallowlist/config_test.go similarity index 98% rename from precompile/contracts/deployerallowlist/deployerallowlisttest/config_test.go rename to precompile/contracts/deployerallowlist/config_test.go index 0bad959a4a..6dc731b904 100644 --- a/precompile/contracts/deployerallowlist/deployerallowlisttest/config_test.go +++ b/precompile/contracts/deployerallowlist/config_test.go @@ -1,7 +1,7 @@ // Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package deployerallowlisttest +package deployerallowlist_test import ( "testing" diff --git a/precompile/contracts/deployerallowlist/deployerallowlisttest/contract_test.go b/precompile/contracts/deployerallowlist/contract_test.go similarity index 93% rename from precompile/contracts/deployerallowlist/deployerallowlisttest/contract_test.go rename to precompile/contracts/deployerallowlist/contract_test.go index cdbd234451..4807ede717 100644 --- a/precompile/contracts/deployerallowlist/deployerallowlisttest/contract_test.go +++ b/precompile/contracts/deployerallowlist/contract_test.go @@ -1,7 +1,7 @@ // Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package deployerallowlisttest +package deployerallowlist_test import ( "testing" diff --git a/precompile/contracts/deployerallowlist/deployerallowlisttest/simulated_test.go b/precompile/contracts/deployerallowlist/simulated_test.go similarity index 59% rename from precompile/contracts/deployerallowlist/deployerallowlisttest/simulated_test.go rename to precompile/contracts/deployerallowlist/simulated_test.go index d557cb6fbf..fbc08ed87e 100644 --- a/precompile/contracts/deployerallowlist/deployerallowlisttest/simulated_test.go +++ b/precompile/contracts/deployerallowlist/simulated_test.go @@ -1,12 +1,9 @@ // Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -// -// This test suite migrates the Hardhat tests for the ContractDeployerAllowList -// to Go using the simulated backend and the generated bindings in this package. -package deployerallowlisttest + +package deployerallowlist_test import ( - "crypto/ecdsa" "math/big" "testing" @@ -24,9 +21,11 @@ import ( "github.com/ava-labs/subnet-evm/precompile/allowlist" "github.com/ava-labs/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/subnet-evm/precompile/contracts/deployerallowlist" + "github.com/ava-labs/subnet-evm/precompile/contracts/testutils" "github.com/ava-labs/subnet-evm/utils" sim "github.com/ava-labs/subnet-evm/ethclient/simulated" + allowlistbindings "github.com/ava-labs/subnet-evm/precompile/allowlist/allowlisttest/bindings" ) var ( @@ -45,18 +44,9 @@ func TestMain(m *testing.M) { m.Run() } -func newAuth(t *testing.T, key *ecdsa.PrivateKey, chainID *big.Int) *bind.TransactOpts { - t.Helper() - auth, err := bind.NewKeyedTransactorWithChainID(key, chainID) - require.NoError(t, err) - return auth -} - func newBackendWithDeployerAllowList(t *testing.T) *sim.Backend { t.Helper() chainCfg := params.Copy(params.TestChainConfig) - // Match the simulated backend chain ID used for signing (1337). - chainCfg.ChainID = big.NewInt(1337) // Enable ContractDeployerAllowList at genesis with admin set to adminAddress. params.GetExtra(&chainCfg).GenesisPrecompiles = extras.Precompiles{ deployerallowlist.ConfigKey: deployerallowlist.NewConfig(utils.NewUint64(0), []common.Address{adminAddress}, nil, nil), @@ -70,70 +60,46 @@ func newBackendWithDeployerAllowList(t *testing.T) *sim.Backend { ) } -func waitReceipt(t *testing.T, b *sim.Backend, tx *types.Transaction) *types.Receipt { - t.Helper() - b.Commit(true) - receipt, err := b.Client().TransactionReceipt(t.Context(), tx.Hash()) - require.NoError(t, err, "failed to get transaction receipt") - return receipt -} - // Helper functions to reduce test boilerplate -func deployAllowListTestContract(t *testing.T, b *sim.Backend, auth *bind.TransactOpts) (common.Address, *allowlisttest.AllowListTest) { +func deployAllowListTest(t *testing.T, b *sim.Backend, auth *bind.TransactOpts) (common.Address, *allowlistbindings.AllowListTest) { t.Helper() - addr, tx, contract, err := allowlisttest.DeployAllowListTest(auth, b.Client(), deployerallowlist.ContractAddress) + addr, tx, contract, err := allowlistbindings.DeployAllowListTest(auth, b.Client(), deployerallowlist.ContractAddress) require.NoError(t, err) - receipt := waitReceipt(t, b, tx) - require.Equal(t, types.ReceiptStatusSuccessful, receipt.Status) + testutils.WaitReceiptSuccessful(t, b, tx) return addr, contract } -func verifyRole(t *testing.T, allowList *allowlisttest.IAllowList, address common.Address, expectedRole allowlist.Role) { - t.Helper() - role, err := allowList.ReadAllowList(nil, address) - require.NoError(t, err) - require.Equal(t, expectedRole.Big(), role) -} - -func setAsAdmin(t *testing.T, b *sim.Backend, allowList *allowlisttest.IAllowList, auth *bind.TransactOpts, address common.Address) { - t.Helper() - tx, err := allowList.SetAdmin(auth, address) - require.NoError(t, err) - receipt := waitReceipt(t, b, tx) - require.Equal(t, types.ReceiptStatusSuccessful, receipt.Status) -} - func TestDeployerAllowList(t *testing.T) { - chainID := big.NewInt(1337) - admin := newAuth(t, adminKey, chainID) - unprivileged := newAuth(t, unprivilegedKey, chainID) + chainID := params.TestChainConfig.ChainID + admin := testutils.NewAuth(t, adminKey, chainID) + unprivileged := testutils.NewAuth(t, unprivilegedKey, chainID) type testCase struct { name string - test func(t *testing.T, backend *sim.Backend, precompileIntf *allowlisttest.IAllowList) + test func(t *testing.T, backend *sim.Backend, precompileIntf *allowlistbindings.IAllowList) } testCases := []testCase{ { name: "should verify sender is admin", - test: func(t *testing.T, _ *sim.Backend, allowList *allowlisttest.IAllowList) { - verifyRole(t, allowList, adminAddress, allowlist.AdminRole) + test: func(t *testing.T, _ *sim.Backend, allowList *allowlistbindings.IAllowList) { + allowlisttest.VerifyRole(t, allowList, adminAddress, allowlist.AdminRole) }, }, { name: "should verify new address has no role", - test: func(t *testing.T, backend *sim.Backend, allowList *allowlisttest.IAllowList) { - allowListTestAddr, _ := deployAllowListTestContract(t, backend, admin) - verifyRole(t, allowList, allowListTestAddr, allowlist.NoRole) + test: func(t *testing.T, backend *sim.Backend, allowList *allowlistbindings.IAllowList) { + allowListTestAddr, _ := deployAllowListTest(t, backend, admin) + allowlisttest.VerifyRole(t, allowList, allowListTestAddr, allowlist.NoRole) }, }, { name: "should verify contract correctly reports admin status", - test: func(t *testing.T, backend *sim.Backend, allowList *allowlisttest.IAllowList) { - allowListTestAddr, allowListTest := deployAllowListTestContract(t, backend, admin) + test: func(t *testing.T, backend *sim.Backend, allowList *allowlistbindings.IAllowList) { + allowListTestAddr, allowListTest := deployAllowListTest(t, backend, admin) - verifyRole(t, allowList, allowListTestAddr, allowlist.NoRole) + allowlisttest.VerifyRole(t, allowList, allowListTestAddr, allowlist.NoRole) isAdmin, err := allowListTest.IsAdmin(nil, allowListTestAddr) require.NoError(t, err) @@ -146,10 +112,10 @@ func TestDeployerAllowList(t *testing.T) { }, { name: "should not let address with no role deploy contracts", - test: func(t *testing.T, backend *sim.Backend, allowList *allowlisttest.IAllowList) { - verifyRole(t, allowList, unprivilegedAddress, allowlist.NoRole) + test: func(t *testing.T, backend *sim.Backend, allowList *allowlistbindings.IAllowList) { + allowlisttest.VerifyRole(t, allowList, unprivilegedAddress, allowlist.NoRole) - _, allowListTest := deployAllowListTestContract(t, backend, admin) + _, allowListTest := deployAllowListTest(t, backend, admin) // Try to deploy via unprivileged user - should fail _, err := allowListTest.DeployContract(unprivileged) @@ -159,12 +125,12 @@ func TestDeployerAllowList(t *testing.T) { }, { name: "should allow admin to add contract as admin via precompile", - test: func(t *testing.T, backend *sim.Backend, allowList *allowlisttest.IAllowList) { - allowListTestAddr, allowListTest := deployAllowListTestContract(t, backend, admin) + test: func(t *testing.T, backend *sim.Backend, allowList *allowlistbindings.IAllowList) { + allowListTestAddr, allowListTest := deployAllowListTest(t, backend, admin) - verifyRole(t, allowList, allowListTestAddr, allowlist.NoRole) - setAsAdmin(t, backend, allowList, admin, allowListTestAddr) - verifyRole(t, allowList, allowListTestAddr, allowlist.AdminRole) + allowlisttest.VerifyRole(t, allowList, allowListTestAddr, allowlist.NoRole) + allowlisttest.SetAsAdmin(t, backend, allowList, admin, allowListTestAddr) + allowlisttest.VerifyRole(t, allowList, allowListTestAddr, allowlist.AdminRole) isAdmin, err := allowListTest.IsAdmin(nil, allowListTestAddr) require.NoError(t, err) @@ -173,35 +139,35 @@ func TestDeployerAllowList(t *testing.T) { }, { name: "should allow admin to add deployer via contract", - test: func(t *testing.T, backend *sim.Backend, allowList *allowlisttest.IAllowList) { - allowListTestAddr, allowListTest := deployAllowListTestContract(t, backend, admin) - otherContractAddr, _ := deployAllowListTestContract(t, backend, admin) + test: func(t *testing.T, backend *sim.Backend, allowList *allowlistbindings.IAllowList) { + allowListTestAddr, allowListTest := deployAllowListTest(t, backend, admin) + otherContractAddr, _ := deployAllowListTest(t, backend, admin) - verifyRole(t, allowList, allowListTestAddr, allowlist.NoRole) - setAsAdmin(t, backend, allowList, admin, allowListTestAddr) - verifyRole(t, allowList, allowListTestAddr, allowlist.AdminRole) + allowlisttest.VerifyRole(t, allowList, allowListTestAddr, allowlist.NoRole) + allowlisttest.SetAsAdmin(t, backend, allowList, admin, allowListTestAddr) + allowlisttest.VerifyRole(t, allowList, allowListTestAddr, allowlist.AdminRole) tx, err := allowListTest.SetEnabled(admin, otherContractAddr) require.NoError(t, err) - waitReceipt(t, backend, tx) + testutils.WaitReceipt(t, backend, tx) isEnabled, err := allowListTest.IsEnabled(nil, otherContractAddr) require.NoError(t, err) require.True(t, isEnabled) - verifyRole(t, allowList, otherContractAddr, allowlist.EnabledRole) + allowlisttest.VerifyRole(t, allowList, otherContractAddr, allowlist.EnabledRole) }, }, { name: "should allow enabled address to deploy contracts", - test: func(t *testing.T, backend *sim.Backend, allowList *allowlisttest.IAllowList) { - allowListTestAddr, allowListTest := deployAllowListTestContract(t, backend, admin) - deployerContractAddr, deployerContract := deployAllowListTestContract(t, backend, admin) + test: func(t *testing.T, backend *sim.Backend, allowList *allowlistbindings.IAllowList) { + allowListTestAddr, allowListTest := deployAllowListTest(t, backend, admin) + deployerContractAddr, deployerContract := deployAllowListTest(t, backend, admin) - setAsAdmin(t, backend, allowList, admin, allowListTestAddr) + allowlisttest.SetAsAdmin(t, backend, allowList, admin, allowListTestAddr) tx, err := allowListTest.SetEnabled(admin, deployerContractAddr) require.NoError(t, err) - waitReceipt(t, backend, tx) + testutils.WaitReceipt(t, backend, tx) isEnabled, err := allowListTest.IsEnabled(nil, deployerContractAddr) require.NoError(t, err) @@ -209,21 +175,20 @@ func TestDeployerAllowList(t *testing.T) { tx, err = deployerContract.DeployContract(admin) require.NoError(t, err) - receipt := waitReceipt(t, backend, tx) - require.Equal(t, types.ReceiptStatusSuccessful, receipt.Status) + testutils.WaitReceiptSuccessful(t, backend, tx) }, }, { name: "should allow admin to revoke deployer", - test: func(t *testing.T, backend *sim.Backend, allowList *allowlisttest.IAllowList) { - allowListTestAddr, allowListTest := deployAllowListTestContract(t, backend, admin) - deployerContractAddr, _ := deployAllowListTestContract(t, backend, admin) + test: func(t *testing.T, backend *sim.Backend, allowList *allowlistbindings.IAllowList) { + allowListTestAddr, allowListTest := deployAllowListTest(t, backend, admin) + deployerContractAddr, _ := deployAllowListTest(t, backend, admin) - setAsAdmin(t, backend, allowList, admin, allowListTestAddr) + allowlisttest.SetAsAdmin(t, backend, allowList, admin, allowListTestAddr) tx, err := allowListTest.SetEnabled(admin, deployerContractAddr) require.NoError(t, err) - waitReceipt(t, backend, tx) + testutils.WaitReceipt(t, backend, tx) isEnabled, err := allowListTest.IsEnabled(nil, deployerContractAddr) require.NoError(t, err) @@ -231,9 +196,9 @@ func TestDeployerAllowList(t *testing.T) { tx, err = allowListTest.Revoke(admin, deployerContractAddr) require.NoError(t, err) - waitReceipt(t, backend, tx) + testutils.WaitReceipt(t, backend, tx) - verifyRole(t, allowList, deployerContractAddr, allowlist.NoRole) + allowlisttest.VerifyRole(t, allowList, deployerContractAddr, allowlist.NoRole) }, }, } @@ -243,7 +208,7 @@ func TestDeployerAllowList(t *testing.T) { backend := newBackendWithDeployerAllowList(t) defer backend.Close() - allowList, err := allowlisttest.NewIAllowList(deployerallowlist.ContractAddress, backend.Client()) + allowList, err := allowlistbindings.NewIAllowList(deployerallowlist.ContractAddress, backend.Client()) require.NoError(t, err) tc.test(t, backend, allowList) @@ -252,26 +217,26 @@ func TestDeployerAllowList(t *testing.T) { } func TestIAllowList_Events(t *testing.T) { - chainID := big.NewInt(1337) - admin := newAuth(t, adminKey, chainID) + chainID := params.TestChainConfig.ChainID + admin := testutils.NewAuth(t, adminKey, chainID) testKey, _ := crypto.GenerateKey() testAddress := crypto.PubkeyToAddress(testKey.PublicKey) type testCase struct { name string - testRun func(*allowlisttest.IAllowList, *bind.TransactOpts, *sim.Backend, *testing.T, common.Address) - expectedEvents []allowlisttest.IAllowListRoleSet + testRun func(*allowlistbindings.IAllowList, *bind.TransactOpts, *sim.Backend, *testing.T, common.Address) + expectedEvents []allowlistbindings.IAllowListRoleSet } testCases := []testCase{ { name: "should emit event after set admin", - testRun: func(allowList *allowlisttest.IAllowList, auth *bind.TransactOpts, backend *sim.Backend, t *testing.T, addr common.Address) { + testRun: func(allowList *allowlistbindings.IAllowList, auth *bind.TransactOpts, backend *sim.Backend, t *testing.T, addr common.Address) { tx, err := allowList.SetAdmin(auth, addr) require.NoError(t, err) - waitReceipt(t, backend, tx) + testutils.WaitReceipt(t, backend, tx) }, - expectedEvents: []allowlisttest.IAllowListRoleSet{ + expectedEvents: []allowlistbindings.IAllowListRoleSet{ { Role: allowlist.AdminRole.Big(), Account: testAddress, @@ -282,12 +247,12 @@ func TestIAllowList_Events(t *testing.T) { }, { name: "should emit event after set manager", - testRun: func(allowList *allowlisttest.IAllowList, auth *bind.TransactOpts, backend *sim.Backend, t *testing.T, addr common.Address) { + testRun: func(allowList *allowlistbindings.IAllowList, auth *bind.TransactOpts, backend *sim.Backend, t *testing.T, addr common.Address) { tx, err := allowList.SetManager(auth, addr) require.NoError(t, err) - waitReceipt(t, backend, tx) + testutils.WaitReceipt(t, backend, tx) }, - expectedEvents: []allowlisttest.IAllowListRoleSet{ + expectedEvents: []allowlistbindings.IAllowListRoleSet{ { Role: allowlist.ManagerRole.Big(), Account: testAddress, @@ -298,12 +263,12 @@ func TestIAllowList_Events(t *testing.T) { }, { name: "should emit event after set enabled", - testRun: func(allowList *allowlisttest.IAllowList, auth *bind.TransactOpts, backend *sim.Backend, t *testing.T, addr common.Address) { + testRun: func(allowList *allowlistbindings.IAllowList, auth *bind.TransactOpts, backend *sim.Backend, t *testing.T, addr common.Address) { tx, err := allowList.SetEnabled(auth, addr) require.NoError(t, err) - waitReceipt(t, backend, tx) + testutils.WaitReceipt(t, backend, tx) }, - expectedEvents: []allowlisttest.IAllowListRoleSet{ + expectedEvents: []allowlistbindings.IAllowListRoleSet{ { Role: allowlist.EnabledRole.Big(), Account: testAddress, @@ -314,17 +279,17 @@ func TestIAllowList_Events(t *testing.T) { }, { name: "should emit event after set none", - testRun: func(allowList *allowlisttest.IAllowList, auth *bind.TransactOpts, backend *sim.Backend, t *testing.T, addr common.Address) { + testRun: func(allowList *allowlistbindings.IAllowList, auth *bind.TransactOpts, backend *sim.Backend, t *testing.T, addr common.Address) { // First set the address to Enabled so we can test setting it to None tx, err := allowList.SetEnabled(auth, addr) require.NoError(t, err) - waitReceipt(t, backend, tx) + testutils.WaitReceipt(t, backend, tx) tx, err = allowList.SetNone(auth, addr) require.NoError(t, err) - waitReceipt(t, backend, tx) + testutils.WaitReceipt(t, backend, tx) }, - expectedEvents: []allowlisttest.IAllowListRoleSet{ + expectedEvents: []allowlistbindings.IAllowListRoleSet{ { Role: allowlist.EnabledRole.Big(), Account: testAddress, @@ -348,7 +313,7 @@ func TestIAllowList_Events(t *testing.T) { backend := newBackendWithDeployerAllowList(t) defer backend.Close() - allowList, err := allowlisttest.NewIAllowList(deployerallowlist.ContractAddress, backend.Client()) + allowList, err := allowlistbindings.NewIAllowList(deployerallowlist.ContractAddress, backend.Client()) require.NoError(err) tc.testRun(allowList, admin, backend, t, testAddress) diff --git a/precompile/contracts/feemanager/config_test.go b/precompile/contracts/feemanager/config_test.go index c0e1062dd0..170faf47fd 100644 --- a/precompile/contracts/feemanager/config_test.go +++ b/precompile/contracts/feemanager/config_test.go @@ -1,7 +1,7 @@ // Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package feemanager +package feemanager_test import ( "math/big" @@ -12,6 +12,7 @@ import ( "github.com/ava-labs/subnet-evm/commontype" "github.com/ava-labs/subnet-evm/precompile/allowlist/allowlisttest" + "github.com/ava-labs/subnet-evm/precompile/contracts/feemanager" "github.com/ava-labs/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/subnet-evm/precompile/precompiletest" "github.com/ava-labs/subnet-evm/utils" @@ -36,15 +37,15 @@ func TestVerify(t *testing.T) { invalidFeeConfig.GasLimit = big.NewInt(0) tests := map[string]precompiletest.ConfigVerifyTest{ "invalid initial fee manager config": { - Config: NewConfig(utils.NewUint64(3), admins, nil, nil, &invalidFeeConfig), + Config: feemanager.NewConfig(utils.NewUint64(3), admins, nil, nil, &invalidFeeConfig), ExpectedError: "gasLimit = 0 cannot be less than or equal to 0", }, "nil initial fee manager config": { - Config: NewConfig(utils.NewUint64(3), admins, nil, nil, &commontype.FeeConfig{}), + Config: feemanager.NewConfig(utils.NewUint64(3), admins, nil, nil, &commontype.FeeConfig{}), ExpectedError: "gasLimit cannot be nil", }, } - allowlisttest.VerifyPrecompileWithAllowListTests(t, Module, tests) + allowlisttest.VerifyPrecompileWithAllowListTests(t, feemanager.Module, tests) } func TestEqual(t *testing.T) { @@ -52,28 +53,28 @@ func TestEqual(t *testing.T) { enableds := []common.Address{allowlisttest.TestEnabledAddr} tests := map[string]precompiletest.ConfigEqualTest{ "non-nil config and nil other": { - Config: NewConfig(utils.NewUint64(3), admins, enableds, nil, nil), + Config: feemanager.NewConfig(utils.NewUint64(3), admins, enableds, nil, nil), Other: nil, Expected: false, }, "different type": { - Config: NewConfig(utils.NewUint64(3), admins, enableds, nil, nil), + Config: feemanager.NewConfig(utils.NewUint64(3), admins, enableds, nil, nil), Other: precompileconfig.NewMockConfig(gomock.NewController(t)), Expected: false, }, "different timestamp": { - Config: NewConfig(utils.NewUint64(3), admins, nil, nil, nil), - Other: NewConfig(utils.NewUint64(4), admins, nil, nil, nil), + Config: feemanager.NewConfig(utils.NewUint64(3), admins, nil, nil, nil), + Other: feemanager.NewConfig(utils.NewUint64(4), admins, nil, nil, nil), Expected: false, }, "non-nil initial config and nil initial config": { - Config: NewConfig(utils.NewUint64(3), admins, nil, nil, &validFeeConfig), - Other: NewConfig(utils.NewUint64(3), admins, nil, nil, nil), + Config: feemanager.NewConfig(utils.NewUint64(3), admins, nil, nil, &validFeeConfig), + Other: feemanager.NewConfig(utils.NewUint64(3), admins, nil, nil, nil), Expected: false, }, "different initial config": { - Config: NewConfig(utils.NewUint64(3), admins, nil, nil, &validFeeConfig), - Other: NewConfig(utils.NewUint64(3), admins, nil, nil, + Config: feemanager.NewConfig(utils.NewUint64(3), admins, nil, nil, &validFeeConfig), + Other: feemanager.NewConfig(utils.NewUint64(3), admins, nil, nil, func() *commontype.FeeConfig { c := validFeeConfig c.GasLimit = big.NewInt(123) @@ -82,10 +83,10 @@ func TestEqual(t *testing.T) { Expected: false, }, "same config": { - Config: NewConfig(utils.NewUint64(3), admins, nil, nil, &validFeeConfig), - Other: NewConfig(utils.NewUint64(3), admins, nil, nil, &validFeeConfig), + Config: feemanager.NewConfig(utils.NewUint64(3), admins, nil, nil, &validFeeConfig), + Other: feemanager.NewConfig(utils.NewUint64(3), admins, nil, nil, &validFeeConfig), Expected: true, }, } - allowlisttest.EqualPrecompileWithAllowListTests(t, Module, tests) + allowlisttest.EqualPrecompileWithAllowListTests(t, feemanager.Module, tests) } diff --git a/precompile/contracts/feemanager/contract_test.go b/precompile/contracts/feemanager/contract_test.go index fe1dc67bfc..0dbad29244 100644 --- a/precompile/contracts/feemanager/contract_test.go +++ b/precompile/contracts/feemanager/contract_test.go @@ -1,7 +1,7 @@ // Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package feemanager +package feemanager_test import ( "math/big" @@ -16,6 +16,7 @@ import ( "github.com/ava-labs/subnet-evm/core/extstate" "github.com/ava-labs/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/subnet-evm/precompile/contract" + "github.com/ava-labs/subnet-evm/precompile/contracts/feemanager" "github.com/ava-labs/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/subnet-evm/precompile/precompiletest" @@ -34,18 +35,7 @@ var ( MaxBlockGasCost: big.NewInt(2000000000000000000), BlockGasCostStep: big.NewInt(1000000000000000000), } - testFeeConfig = commontype.FeeConfig{ - GasLimit: big.NewInt(8_000_000), - TargetBlockRate: 2, // in seconds - - MinBaseFee: big.NewInt(25_000_000_000), - TargetGas: big.NewInt(15_000_000), - BaseFeeChangeDenominator: big.NewInt(36), - - MinBlockGasCost: big.NewInt(0), - MaxBlockGasCost: big.NewInt(1_000_000), - BlockGasCostStep: big.NewInt(200_000), - } + testFeeConfig = commontype.ValidTestFeeConfig zeroFeeConfig = commontype.FeeConfig{ GasLimit: new(big.Int), MinBaseFee: new(big.Int), @@ -61,32 +51,32 @@ var ( { Name: "set_config_from_no_role_fails", Caller: allowlisttest.TestNoRoleAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(feemanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackSetFeeConfig(testFeeConfig) + input, err := feemanager.PackSetFeeConfig(testFeeConfig) require.NoError(t, err) return input }, - SuppliedGas: SetFeeConfigGasCost, + SuppliedGas: feemanager.SetFeeConfigGasCost, ReadOnly: false, - ExpectedErr: ErrCannotChangeFee.Error(), + ExpectedErr: feemanager.ErrCannotChangeFee.Error(), }, { Name: "set_config_from_enabled_address_succeeds_and_emits_logs", Caller: allowlisttest.TestEnabledAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(feemanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackSetFeeConfig(testFeeConfig) + input, err := feemanager.PackSetFeeConfig(testFeeConfig) require.NoError(t, err) return input }, - SuppliedGas: SetFeeConfigGasCost + FeeConfigChangedEventGasCost, + SuppliedGas: feemanager.SetFeeConfigGasCost + feemanager.FeeConfigChangedEventGasCost, ReadOnly: false, ExpectedRes: []byte{}, AfterHook: func(t testing.TB, state *extstate.StateDB) { - feeConfig := GetStoredFeeConfig(state) + feeConfig := feemanager.GetStoredFeeConfig(state) require.Equal(t, testFeeConfig, feeConfig) logs := state.Logs() @@ -96,18 +86,18 @@ var ( { Name: "set_config_from_manager_succeeds", Caller: allowlisttest.TestManagerAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(feemanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackSetFeeConfig(testFeeConfig) + input, err := feemanager.PackSetFeeConfig(testFeeConfig) require.NoError(t, err) return input }, - SuppliedGas: SetFeeConfigGasCost + FeeConfigChangedEventGasCost, + SuppliedGas: feemanager.SetFeeConfigGasCost + feemanager.FeeConfigChangedEventGasCost, ReadOnly: false, ExpectedRes: []byte{}, AfterHook: func(t testing.TB, state *extstate.StateDB) { - feeConfig := GetStoredFeeConfig(state) + feeConfig := feemanager.GetStoredFeeConfig(state) require.Equal(t, testFeeConfig, feeConfig) logs := state.Logs() @@ -117,37 +107,37 @@ var ( { Name: "set_invalid_config_from_enabled_address", Caller: allowlisttest.TestEnabledAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(feemanager.Module.Address), InputFn: func(t testing.TB) []byte { feeConfig := testFeeConfig feeConfig.MinBlockGasCost = new(big.Int).Mul(feeConfig.MaxBlockGasCost, common.Big2) - input, err := PackSetFeeConfig(feeConfig) + input, err := feemanager.PackSetFeeConfig(feeConfig) require.NoError(t, err) return input }, - SuppliedGas: SetFeeConfigGasCost + FeeConfigChangedEventGasCost, + SuppliedGas: feemanager.SetFeeConfigGasCost + feemanager.FeeConfigChangedEventGasCost, ReadOnly: false, - Config: &Config{ + Config: &feemanager.Config{ InitialFeeConfig: &testFeeConfig, }, ExpectedErr: "cannot be greater than maxBlockGasCost", AfterHook: func(t testing.TB, state *extstate.StateDB) { - feeConfig := GetStoredFeeConfig(state) + feeConfig := feemanager.GetStoredFeeConfig(state) require.Equal(t, testFeeConfig, feeConfig) }, }, { Name: "set_config_from_admin_address", Caller: allowlisttest.TestAdminAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(feemanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackSetFeeConfig(testFeeConfig) + input, err := feemanager.PackSetFeeConfig(testFeeConfig) require.NoError(t, err) return input }, - SuppliedGas: SetFeeConfigGasCost + FeeConfigChangedEventGasCost, + SuppliedGas: feemanager.SetFeeConfigGasCost + feemanager.FeeConfigChangedEventGasCost, ReadOnly: false, ExpectedRes: []byte{}, SetupBlockContext: func(mbc *contract.MockBlockContext) { @@ -155,9 +145,9 @@ var ( mbc.EXPECT().Timestamp().Return(uint64(0)).AnyTimes() }, AfterHook: func(t testing.TB, state *extstate.StateDB) { - feeConfig := GetStoredFeeConfig(state) + feeConfig := feemanager.GetStoredFeeConfig(state) require.Equal(t, testFeeConfig, feeConfig) - lastChangedAt := GetFeeConfigLastChangedAt(state) + lastChangedAt := feemanager.GetFeeConfigLastChangedAt(state) require.Equal(t, testBlockNumber, lastChangedAt) logs := state.Logs() @@ -170,27 +160,27 @@ var ( BeforeHook: func(t testing.TB, state *extstate.StateDB) { blockContext := contract.NewMockBlockContext(gomock.NewController(t)) blockContext.EXPECT().Number().Return(big.NewInt(6)).Times(1) - allowlisttest.SetDefaultRoles(Module.Address)(t, state) - require.NoError(t, StoreFeeConfig(state, testFeeConfig, blockContext)) + allowlisttest.SetDefaultRoles(feemanager.Module.Address)(t, state) + require.NoError(t, feemanager.StoreFeeConfig(state, testFeeConfig, blockContext)) }, InputFn: func(t testing.TB) []byte { - input, err := PackGetFeeConfig() + input, err := feemanager.PackGetFeeConfig() require.NoError(t, err) return input }, - SuppliedGas: GetFeeConfigGasCost, + SuppliedGas: feemanager.GetFeeConfigGasCost, ReadOnly: true, ExpectedRes: func() []byte { - res, err := PackGetFeeConfigOutput(testFeeConfig) + res, err := feemanager.PackGetFeeConfigOutput(testFeeConfig) if err != nil { panic(err) } return res }(), AfterHook: func(t testing.TB, state *extstate.StateDB) { - feeConfig := GetStoredFeeConfig(state) - lastChangedAt := GetFeeConfigLastChangedAt(state) + feeConfig := feemanager.GetStoredFeeConfig(state) + lastChangedAt := feemanager.GetFeeConfigLastChangedAt(state) require.Equal(t, testFeeConfig, feeConfig) require.Equal(t, big.NewInt(6), lastChangedAt) }, @@ -198,20 +188,20 @@ var ( { Name: "get_initial_fee_config", Caller: allowlisttest.TestNoRoleAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(feemanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackGetFeeConfig() + input, err := feemanager.PackGetFeeConfig() require.NoError(t, err) return input }, - SuppliedGas: GetFeeConfigGasCost, + SuppliedGas: feemanager.GetFeeConfigGasCost, ReadOnly: true, - Config: &Config{ + Config: &feemanager.Config{ InitialFeeConfig: &testFeeConfig, }, ExpectedRes: func() []byte { - res, err := PackGetFeeConfigOutput(testFeeConfig) + res, err := feemanager.PackGetFeeConfigOutput(testFeeConfig) if err != nil { panic(err) } @@ -221,8 +211,8 @@ var ( mbc.EXPECT().Number().Return(testBlockNumber) }, AfterHook: func(t testing.TB, state *extstate.StateDB) { - feeConfig := GetStoredFeeConfig(state) - lastChangedAt := GetFeeConfigLastChangedAt(state) + feeConfig := feemanager.GetStoredFeeConfig(state) + lastChangedAt := feemanager.GetFeeConfigLastChangedAt(state) require.Equal(t, testFeeConfig, feeConfig) require.Equal(t, testBlockNumber, lastChangedAt) }, @@ -233,27 +223,27 @@ var ( BeforeHook: func(t testing.TB, state *extstate.StateDB) { blockContext := contract.NewMockBlockContext(gomock.NewController(t)) blockContext.EXPECT().Number().Return(testBlockNumber).Times(1) - allowlisttest.SetDefaultRoles(Module.Address)(t, state) - require.NoError(t, StoreFeeConfig(state, testFeeConfig, blockContext)) + allowlisttest.SetDefaultRoles(feemanager.Module.Address)(t, state) + require.NoError(t, feemanager.StoreFeeConfig(state, testFeeConfig, blockContext)) }, InputFn: func(t testing.TB) []byte { - input, err := PackGetFeeConfigLastChangedAt() + input, err := feemanager.PackGetFeeConfigLastChangedAt() require.NoError(t, err) return input }, - SuppliedGas: GetLastChangedAtGasCost, + SuppliedGas: feemanager.GetLastChangedAtGasCost, ReadOnly: true, ExpectedRes: func() []byte { - res, err := PackGetFeeConfigLastChangedAtOutput(testBlockNumber) + res, err := feemanager.PackGetFeeConfigLastChangedAtOutput(testBlockNumber) if err != nil { panic(err) } return res }(), AfterHook: func(t testing.TB, state *extstate.StateDB) { - feeConfig := GetStoredFeeConfig(state) - lastChangedAt := GetFeeConfigLastChangedAt(state) + feeConfig := feemanager.GetStoredFeeConfig(state) + lastChangedAt := feemanager.GetFeeConfigLastChangedAt(state) require.Equal(t, testFeeConfig, feeConfig) require.Equal(t, testBlockNumber, lastChangedAt) }, @@ -261,65 +251,65 @@ var ( { Name: "readOnly_setFeeConfig_with_noRole_fails", Caller: allowlisttest.TestNoRoleAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(feemanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackSetFeeConfig(testFeeConfig) + input, err := feemanager.PackSetFeeConfig(testFeeConfig) require.NoError(t, err) return input }, - SuppliedGas: SetFeeConfigGasCost, + SuppliedGas: feemanager.SetFeeConfigGasCost, ReadOnly: true, ExpectedErr: vm.ErrWriteProtection.Error(), }, { Name: "readOnly_setFeeConfig_with_allow_role_fails", Caller: allowlisttest.TestEnabledAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(feemanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackSetFeeConfig(testFeeConfig) + input, err := feemanager.PackSetFeeConfig(testFeeConfig) require.NoError(t, err) return input }, - SuppliedGas: SetFeeConfigGasCost, + SuppliedGas: feemanager.SetFeeConfigGasCost, ReadOnly: true, ExpectedErr: vm.ErrWriteProtection.Error(), }, { Name: "readOnly_setFeeConfig_with_admin_role_fails", Caller: allowlisttest.TestAdminAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(feemanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackSetFeeConfig(testFeeConfig) + input, err := feemanager.PackSetFeeConfig(testFeeConfig) require.NoError(t, err) return input }, - SuppliedGas: SetFeeConfigGasCost, + SuppliedGas: feemanager.SetFeeConfigGasCost, ReadOnly: true, ExpectedErr: vm.ErrWriteProtection.Error(), }, { Name: "insufficient_gas_setFeeConfig_from_admin", Caller: allowlisttest.TestAdminAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(feemanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackSetFeeConfig(testFeeConfig) + input, err := feemanager.PackSetFeeConfig(testFeeConfig) require.NoError(t, err) return input }, - SuppliedGas: SetFeeConfigGasCost - 1, + SuppliedGas: feemanager.SetFeeConfigGasCost - 1, ReadOnly: false, ExpectedErr: vm.ErrOutOfGas.Error(), }, { Name: "set_config_with_extra_padded_bytes_should_fail_before_Durango", Caller: allowlisttest.TestEnabledAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(feemanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackSetFeeConfig(testFeeConfig) + input, err := feemanager.PackSetFeeConfig(testFeeConfig) require.NoError(t, err) input = append(input, make([]byte, 32)...) @@ -330,9 +320,9 @@ var ( config.EXPECT().IsDurango(gomock.Any()).Return(false).AnyTimes() return config }, - SuppliedGas: SetFeeConfigGasCost, + SuppliedGas: feemanager.SetFeeConfigGasCost, ReadOnly: false, - ExpectedErr: ErrInvalidLen.Error(), + ExpectedErr: feemanager.ErrInvalidLen.Error(), SetupBlockContext: func(mbc *contract.MockBlockContext) { mbc.EXPECT().Number().Return(testBlockNumber).AnyTimes() mbc.EXPECT().Timestamp().Return(uint64(0)).AnyTimes() @@ -341,9 +331,9 @@ var ( { Name: "set_config_with_extra_padded_bytes_should_succeed_with_Durango", Caller: allowlisttest.TestEnabledAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(feemanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackSetFeeConfig(testFeeConfig) + input, err := feemanager.PackSetFeeConfig(testFeeConfig) require.NoError(t, err) input = append(input, make([]byte, 32)...) @@ -354,7 +344,7 @@ var ( config.EXPECT().IsDurango(gomock.Any()).Return(true).AnyTimes() return config }, - SuppliedGas: SetFeeConfigGasCost + FeeConfigChangedEventGasCost, + SuppliedGas: feemanager.SetFeeConfigGasCost + feemanager.FeeConfigChangedEventGasCost, ReadOnly: false, ExpectedRes: []byte{}, SetupBlockContext: func(mbc *contract.MockBlockContext) { @@ -362,9 +352,9 @@ var ( mbc.EXPECT().Timestamp().Return(uint64(0)).AnyTimes() }, AfterHook: func(t testing.TB, state *extstate.StateDB) { - feeConfig := GetStoredFeeConfig(state) + feeConfig := feemanager.GetStoredFeeConfig(state) require.Equal(t, testFeeConfig, feeConfig) - lastChangedAt := GetFeeConfigLastChangedAt(state) + lastChangedAt := feemanager.GetFeeConfigLastChangedAt(state) require.Equal(t, testBlockNumber, lastChangedAt) logs := state.Logs() @@ -375,15 +365,15 @@ var ( { Name: "setFeeConfig_regression_test_should_fail_before_Durango", Caller: allowlisttest.TestEnabledAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(feemanager.Module.Address), Input: common.Hex2Bytes(regressionBytes), ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) config.EXPECT().IsDurango(gomock.Any()).Return(false).AnyTimes() return config }, - SuppliedGas: SetFeeConfigGasCost, - ExpectedErr: ErrInvalidLen.Error(), + SuppliedGas: feemanager.SetFeeConfigGasCost, + ExpectedErr: feemanager.ErrInvalidLen.Error(), ReadOnly: false, SetupBlockContext: func(mbc *contract.MockBlockContext) { mbc.EXPECT().Number().Return(testBlockNumber).AnyTimes() @@ -393,14 +383,14 @@ var ( { Name: "setFeeConfig_regression_test_should_succeed_after_Durango", Caller: allowlisttest.TestEnabledAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(feemanager.Module.Address), Input: common.Hex2Bytes(regressionBytes), ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) config.EXPECT().IsDurango(gomock.Any()).Return(true).AnyTimes() return config }, - SuppliedGas: SetFeeConfigGasCost + FeeConfigChangedEventGasCost, + SuppliedGas: feemanager.SetFeeConfigGasCost + feemanager.FeeConfigChangedEventGasCost, ReadOnly: false, ExpectedRes: []byte{}, SetupBlockContext: func(mbc *contract.MockBlockContext) { @@ -408,9 +398,9 @@ var ( mbc.EXPECT().Timestamp().Return(uint64(0)).AnyTimes() }, AfterHook: func(t testing.TB, state *extstate.StateDB) { - feeConfig := GetStoredFeeConfig(state) + feeConfig := feemanager.GetStoredFeeConfig(state) require.Equal(t, regressionFeeConfig, feeConfig) - lastChangedAt := GetFeeConfigLastChangedAt(state) + lastChangedAt := feemanager.GetFeeConfigLastChangedAt(state) require.Equal(t, testBlockNumber, lastChangedAt) logs := state.Logs() @@ -420,18 +410,18 @@ var ( { Name: "set_config_should_not_emit_event_before_Durango", Caller: allowlisttest.TestEnabledAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(feemanager.Module.Address), ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) config.EXPECT().IsDurango(gomock.Any()).Return(false).AnyTimes() return config }, InputFn: func(t testing.TB) []byte { - input, err := PackSetFeeConfig(testFeeConfig) + input, err := feemanager.PackSetFeeConfig(testFeeConfig) require.NoError(t, err) return input }, - SuppliedGas: SetFeeConfigGasCost, + SuppliedGas: feemanager.SetFeeConfigGasCost, ReadOnly: false, ExpectedRes: []byte{}, AfterHook: func(t testing.TB, state *extstate.StateDB) { @@ -443,7 +433,7 @@ var ( ) func TestFeeManager(t *testing.T) { - allowlisttest.RunPrecompileWithAllowListTests(t, Module, tests) + allowlisttest.RunPrecompileWithAllowListTests(t, feemanager.Module, tests) } func assertFeeEvent( @@ -458,13 +448,13 @@ func assertFeeEvent( require.Equal( t, []common.Hash{ - FeeManagerABI.Events["FeeConfigChanged"].ID, + feemanager.FeeManagerABI.Events["FeeConfigChanged"].ID, common.BytesToHash(sender[:]), }, log.Topics, ) - oldFeeConfig, resFeeConfig, err := UnpackFeeConfigChangedEventData(log.Data) + oldFeeConfig, resFeeConfig, err := feemanager.UnpackFeeConfigChangedEventData(log.Data) require.NoError(t, err) require.True(t, expectedOldFeeConfig.Equal(&oldFeeConfig), "expected %v, got %v", expectedOldFeeConfig, oldFeeConfig) require.True(t, expectedNewFeeConfig.Equal(&resFeeConfig), "expected %v, got %v", expectedNewFeeConfig, resFeeConfig) diff --git a/precompile/contracts/feemanager/unpack_pack_test.go b/precompile/contracts/feemanager/unpack_pack_test.go index 2f46409624..ea8cb590f6 100644 --- a/precompile/contracts/feemanager/unpack_pack_test.go +++ b/precompile/contracts/feemanager/unpack_pack_test.go @@ -21,6 +21,7 @@ var ( setFeeConfigSignature = contract.CalculateFunctionSelector("setFeeConfig(uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256)") getFeeConfigSignature = contract.CalculateFunctionSelector("getFeeConfig()") getFeeConfigLastChangedAtSignature = contract.CalculateFunctionSelector("getFeeConfigLastChangedAt()") + testFeeConfig = commontype.ValidTestFeeConfig ) func FuzzPackGetFeeConfigOutputEqualTest(f *testing.F) { diff --git a/precompile/contracts/nativeminter/config_test.go b/precompile/contracts/nativeminter/config_test.go index 649e16cc59..7472585c04 100644 --- a/precompile/contracts/nativeminter/config_test.go +++ b/precompile/contracts/nativeminter/config_test.go @@ -1,7 +1,7 @@ // Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package nativeminter +package nativeminter_test import ( "testing" @@ -11,6 +11,7 @@ import ( "go.uber.org/mock/gomock" "github.com/ava-labs/subnet-evm/precompile/allowlist/allowlisttest" + "github.com/ava-labs/subnet-evm/precompile/contracts/nativeminter" "github.com/ava-labs/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/subnet-evm/precompile/precompiletest" "github.com/ava-labs/subnet-evm/utils" @@ -22,7 +23,7 @@ func TestVerify(t *testing.T) { managers := []common.Address{allowlisttest.TestManagerAddr} tests := map[string]precompiletest.ConfigVerifyTest{ "valid config": { - Config: NewConfig(utils.NewUint64(3), admins, enableds, managers, nil), + Config: nativeminter.NewConfig(utils.NewUint64(3), admins, enableds, managers, nil), ChainConfig: func() precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(gomock.NewController(t)) config.EXPECT().IsDurango(gomock.Any()).Return(true).AnyTimes() @@ -31,19 +32,19 @@ func TestVerify(t *testing.T) { ExpectedError: "", }, "invalid allow list config in native minter allowlisttest": { - Config: NewConfig(utils.NewUint64(3), admins, admins, nil, nil), + Config: nativeminter.NewConfig(utils.NewUint64(3), admins, admins, nil, nil), ExpectedError: "cannot set address", }, "duplicate admins in config in native minter allowlisttest": { - Config: NewConfig(utils.NewUint64(3), append(admins, admins[0]), enableds, managers, nil), + Config: nativeminter.NewConfig(utils.NewUint64(3), append(admins, admins[0]), enableds, managers, nil), ExpectedError: "duplicate address", }, "duplicate enableds in config in native minter allowlisttest": { - Config: NewConfig(utils.NewUint64(3), admins, append(enableds, enableds[0]), managers, nil), + Config: nativeminter.NewConfig(utils.NewUint64(3), admins, append(enableds, enableds[0]), managers, nil), ExpectedError: "duplicate address", }, "nil amount in native minter config": { - Config: NewConfig(utils.NewUint64(3), admins, nil, nil, + Config: nativeminter.NewConfig(utils.NewUint64(3), admins, nil, nil, map[common.Address]*math.HexOrDecimal256{ common.HexToAddress("0x01"): math.NewHexOrDecimal256(123), common.HexToAddress("0x02"): nil, @@ -51,7 +52,7 @@ func TestVerify(t *testing.T) { ExpectedError: "initial mint cannot contain nil", }, "negative amount in native minter config": { - Config: NewConfig(utils.NewUint64(3), admins, nil, nil, + Config: nativeminter.NewConfig(utils.NewUint64(3), admins, nil, nil, map[common.Address]*math.HexOrDecimal256{ common.HexToAddress("0x01"): math.NewHexOrDecimal256(123), common.HexToAddress("0x02"): math.NewHexOrDecimal256(-1), @@ -59,7 +60,7 @@ func TestVerify(t *testing.T) { ExpectedError: "initial mint cannot contain invalid amount", }, } - allowlisttest.VerifyPrecompileWithAllowListTests(t, Module, tests) + allowlisttest.VerifyPrecompileWithAllowListTests(t, nativeminter.Module, tests) } func TestEqual(t *testing.T) { @@ -68,53 +69,53 @@ func TestEqual(t *testing.T) { managers := []common.Address{allowlisttest.TestManagerAddr} tests := map[string]precompiletest.ConfigEqualTest{ "non-nil config and nil other": { - Config: NewConfig(utils.NewUint64(3), admins, enableds, managers, nil), + Config: nativeminter.NewConfig(utils.NewUint64(3), admins, enableds, managers, nil), Other: nil, Expected: false, }, "different type": { - Config: NewConfig(utils.NewUint64(3), admins, enableds, managers, nil), + Config: nativeminter.NewConfig(utils.NewUint64(3), admins, enableds, managers, nil), Other: precompileconfig.NewMockConfig(gomock.NewController(t)), Expected: false, }, "different timestamp": { - Config: NewConfig(utils.NewUint64(3), admins, nil, nil, nil), - Other: NewConfig(utils.NewUint64(4), admins, nil, nil, nil), + Config: nativeminter.NewConfig(utils.NewUint64(3), admins, nil, nil, nil), + Other: nativeminter.NewConfig(utils.NewUint64(4), admins, nil, nil, nil), Expected: false, }, "different initial mint amounts": { - Config: NewConfig(utils.NewUint64(3), admins, nil, nil, + Config: nativeminter.NewConfig(utils.NewUint64(3), admins, nil, nil, map[common.Address]*math.HexOrDecimal256{ common.HexToAddress("0x01"): math.NewHexOrDecimal256(1), }), - Other: NewConfig(utils.NewUint64(3), admins, nil, nil, + Other: nativeminter.NewConfig(utils.NewUint64(3), admins, nil, nil, map[common.Address]*math.HexOrDecimal256{ common.HexToAddress("0x01"): math.NewHexOrDecimal256(2), }), Expected: false, }, "different initial mint addresses": { - Config: NewConfig(utils.NewUint64(3), admins, nil, nil, + Config: nativeminter.NewConfig(utils.NewUint64(3), admins, nil, nil, map[common.Address]*math.HexOrDecimal256{ common.HexToAddress("0x01"): math.NewHexOrDecimal256(1), }), - Other: NewConfig(utils.NewUint64(3), admins, nil, nil, + Other: nativeminter.NewConfig(utils.NewUint64(3), admins, nil, nil, map[common.Address]*math.HexOrDecimal256{ common.HexToAddress("0x02"): math.NewHexOrDecimal256(1), }), Expected: false, }, "same config": { - Config: NewConfig(utils.NewUint64(3), admins, nil, nil, + Config: nativeminter.NewConfig(utils.NewUint64(3), admins, nil, nil, map[common.Address]*math.HexOrDecimal256{ common.HexToAddress("0x01"): math.NewHexOrDecimal256(1), }), - Other: NewConfig(utils.NewUint64(3), admins, nil, nil, + Other: nativeminter.NewConfig(utils.NewUint64(3), admins, nil, nil, map[common.Address]*math.HexOrDecimal256{ common.HexToAddress("0x01"): math.NewHexOrDecimal256(1), }), Expected: true, }, } - allowlisttest.EqualPrecompileWithAllowListTests(t, Module, tests) + allowlisttest.EqualPrecompileWithAllowListTests(t, nativeminter.Module, tests) } diff --git a/precompile/contracts/nativeminter/contract_test.go b/precompile/contracts/nativeminter/contract_test.go index beb4220d62..ee731e8612 100644 --- a/precompile/contracts/nativeminter/contract_test.go +++ b/precompile/contracts/nativeminter/contract_test.go @@ -1,7 +1,7 @@ // Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package nativeminter +package nativeminter_test import ( "math/big" @@ -16,6 +16,7 @@ import ( "github.com/ava-labs/subnet-evm/core/extstate" "github.com/ava-labs/subnet-evm/precompile/allowlist/allowlisttest" + "github.com/ava-labs/subnet-evm/precompile/contracts/nativeminter" "github.com/ava-labs/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/subnet-evm/precompile/precompiletest" @@ -26,28 +27,28 @@ var tests = []precompiletest.PrecompileTest{ { Name: "calling_mintNativeCoin_from_NoRole_should_fail", Caller: allowlisttest.TestNoRoleAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(nativeminter.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackMintNativeCoin(allowlisttest.TestNoRoleAddr, common.Big1) + input, err := nativeminter.PackMintNativeCoin(allowlisttest.TestNoRoleAddr, common.Big1) require.NoError(t, err) return input }, - SuppliedGas: MintGasCost, + SuppliedGas: nativeminter.MintGasCost, ReadOnly: false, - ExpectedErr: ErrCannotMint.Error(), + ExpectedErr: nativeminter.ErrCannotMint.Error(), }, { Name: "calling_mintNativeCoin_from_Enabled_should_succeed", Caller: allowlisttest.TestEnabledAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(nativeminter.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackMintNativeCoin(allowlisttest.TestEnabledAddr, common.Big1) + input, err := nativeminter.PackMintNativeCoin(allowlisttest.TestEnabledAddr, common.Big1) require.NoError(t, err) return input }, - SuppliedGas: MintGasCost + NativeCoinMintedEventGasCost, + SuppliedGas: nativeminter.MintGasCost + nativeminter.NativeCoinMintedEventGasCost, ReadOnly: false, ExpectedRes: []byte{}, AfterHook: func(t testing.TB, stateDB *extstate.StateDB) { @@ -61,8 +62,8 @@ var tests = []precompiletest.PrecompileTest{ { Name: "initial_mint_funds", Caller: allowlisttest.TestEnabledAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), - Config: &Config{ + BeforeHook: allowlisttest.SetDefaultRoles(nativeminter.Module.Address), + Config: &nativeminter.Config{ InitialMint: map[common.Address]*math.HexOrDecimal256{ allowlisttest.TestEnabledAddr: math.NewHexOrDecimal256(2), }, @@ -75,14 +76,14 @@ var tests = []precompiletest.PrecompileTest{ { Name: "calling_mintNativeCoin_from_Manager_should_succeed", Caller: allowlisttest.TestManagerAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(nativeminter.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackMintNativeCoin(allowlisttest.TestEnabledAddr, common.Big1) + input, err := nativeminter.PackMintNativeCoin(allowlisttest.TestEnabledAddr, common.Big1) require.NoError(t, err) return input }, - SuppliedGas: MintGasCost + NativeCoinMintedEventGasCost, + SuppliedGas: nativeminter.MintGasCost + nativeminter.NativeCoinMintedEventGasCost, ReadOnly: false, ExpectedRes: []byte{}, AfterHook: func(t testing.TB, stateDB *extstate.StateDB) { @@ -96,14 +97,14 @@ var tests = []precompiletest.PrecompileTest{ { Name: "mint_funds_from_admin_address", Caller: allowlisttest.TestAdminAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(nativeminter.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackMintNativeCoin(allowlisttest.TestAdminAddr, common.Big1) + input, err := nativeminter.PackMintNativeCoin(allowlisttest.TestAdminAddr, common.Big1) require.NoError(t, err) return input }, - SuppliedGas: MintGasCost + NativeCoinMintedEventGasCost, + SuppliedGas: nativeminter.MintGasCost + nativeminter.NativeCoinMintedEventGasCost, ReadOnly: false, ExpectedRes: []byte{}, AfterHook: func(t testing.TB, stateDB *extstate.StateDB) { @@ -117,14 +118,14 @@ var tests = []precompiletest.PrecompileTest{ { Name: "mint_max_big_funds", Caller: allowlisttest.TestAdminAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(nativeminter.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackMintNativeCoin(allowlisttest.TestAdminAddr, math.MaxBig256) + input, err := nativeminter.PackMintNativeCoin(allowlisttest.TestAdminAddr, math.MaxBig256) require.NoError(t, err) return input }, - SuppliedGas: MintGasCost + NativeCoinMintedEventGasCost, + SuppliedGas: nativeminter.MintGasCost + nativeminter.NativeCoinMintedEventGasCost, ReadOnly: false, ExpectedRes: []byte{}, AfterHook: func(t testing.TB, stateDB *extstate.StateDB) { @@ -138,74 +139,74 @@ var tests = []precompiletest.PrecompileTest{ { Name: "readOnly_mint_with_noRole_fails", Caller: allowlisttest.TestNoRoleAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(nativeminter.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackMintNativeCoin(allowlisttest.TestAdminAddr, common.Big1) + input, err := nativeminter.PackMintNativeCoin(allowlisttest.TestAdminAddr, common.Big1) require.NoError(t, err) return input }, - SuppliedGas: MintGasCost, + SuppliedGas: nativeminter.MintGasCost, ReadOnly: true, ExpectedErr: vm.ErrWriteProtection.Error(), }, { Name: "readOnly_mint_with_allow_role_fails", Caller: allowlisttest.TestEnabledAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(nativeminter.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackMintNativeCoin(allowlisttest.TestEnabledAddr, common.Big1) + input, err := nativeminter.PackMintNativeCoin(allowlisttest.TestEnabledAddr, common.Big1) require.NoError(t, err) return input }, - SuppliedGas: MintGasCost, + SuppliedGas: nativeminter.MintGasCost, ReadOnly: true, ExpectedErr: vm.ErrWriteProtection.Error(), }, { Name: "readOnly_mint_with_admin_role_fails", Caller: allowlisttest.TestAdminAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(nativeminter.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackMintNativeCoin(allowlisttest.TestAdminAddr, common.Big1) + input, err := nativeminter.PackMintNativeCoin(allowlisttest.TestAdminAddr, common.Big1) require.NoError(t, err) return input }, - SuppliedGas: MintGasCost, + SuppliedGas: nativeminter.MintGasCost, ReadOnly: true, ExpectedErr: vm.ErrWriteProtection.Error(), }, { Name: "insufficient_gas_mint_from_admin", Caller: allowlisttest.TestAdminAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(nativeminter.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackMintNativeCoin(allowlisttest.TestEnabledAddr, common.Big1) + input, err := nativeminter.PackMintNativeCoin(allowlisttest.TestEnabledAddr, common.Big1) require.NoError(t, err) return input }, - SuppliedGas: MintGasCost + NativeCoinMintedEventGasCost - 1, + SuppliedGas: nativeminter.MintGasCost + nativeminter.NativeCoinMintedEventGasCost - 1, ReadOnly: false, ExpectedErr: vm.ErrOutOfGas.Error(), }, { Name: "mint_does_not_log_pre_Durango", Caller: allowlisttest.TestEnabledAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(nativeminter.Module.Address), ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) config.EXPECT().IsDurango(gomock.Any()).Return(false).AnyTimes() return config }, InputFn: func(t testing.TB) []byte { - input, err := PackMintNativeCoin(allowlisttest.TestEnabledAddr, common.Big1) + input, err := nativeminter.PackMintNativeCoin(allowlisttest.TestEnabledAddr, common.Big1) require.NoError(t, err) return input }, - SuppliedGas: MintGasCost, + SuppliedGas: nativeminter.MintGasCost, ReadOnly: false, ExpectedRes: []byte{}, AfterHook: func(t testing.TB, stateDB *extstate.StateDB) { @@ -217,14 +218,14 @@ var tests = []precompiletest.PrecompileTest{ { Name: "mint_with_extra_padded_bytes_should_fail_pre_Durango", Caller: allowlisttest.TestEnabledAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(nativeminter.Module.Address), ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) config.EXPECT().IsDurango(gomock.Any()).Return(false).AnyTimes() return config }, InputFn: func(t testing.TB) []byte { - input, err := PackMintNativeCoin(allowlisttest.TestEnabledAddr, common.Big1) + input, err := nativeminter.PackMintNativeCoin(allowlisttest.TestEnabledAddr, common.Big1) require.NoError(t, err) // Add extra bytes to the end of the input @@ -232,21 +233,21 @@ var tests = []precompiletest.PrecompileTest{ return input }, - SuppliedGas: MintGasCost, + SuppliedGas: nativeminter.MintGasCost, ReadOnly: false, - ExpectedErr: ErrInvalidLen.Error(), + ExpectedErr: nativeminter.ErrInvalidLen.Error(), }, { Name: "mint_with_extra_padded_bytes_should_succeed_with_Durango", Caller: allowlisttest.TestEnabledAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(nativeminter.Module.Address), ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) config.EXPECT().IsDurango(gomock.Any()).Return(true).AnyTimes() return config }, InputFn: func(t testing.TB) []byte { - input, err := PackMintNativeCoin(allowlisttest.TestEnabledAddr, common.Big1) + input, err := nativeminter.PackMintNativeCoin(allowlisttest.TestEnabledAddr, common.Big1) require.NoError(t, err) // Add extra bytes to the end of the input @@ -255,7 +256,7 @@ var tests = []precompiletest.PrecompileTest{ return input }, ExpectedRes: []byte{}, - SuppliedGas: MintGasCost + NativeCoinMintedEventGasCost, + SuppliedGas: nativeminter.MintGasCost + nativeminter.NativeCoinMintedEventGasCost, ReadOnly: false, AfterHook: func(t testing.TB, state *extstate.StateDB) { expected := uint256.MustFromBig(common.Big1) @@ -268,7 +269,7 @@ var tests = []precompiletest.PrecompileTest{ } func TestContractNativeMinterRun(t *testing.T) { - allowlisttest.RunPrecompileWithAllowListTests(t, Module, tests) + allowlisttest.RunPrecompileWithAllowListTests(t, nativeminter.Module, tests) } func assertNativeCoinMintedEvent(t testing.TB, @@ -282,14 +283,14 @@ func assertNativeCoinMintedEvent(t testing.TB, require.Equal( t, []common.Hash{ - NativeMinterABI.Events["NativeCoinMinted"].ID, + nativeminter.NativeMinterABI.Events["NativeCoinMinted"].ID, common.BytesToHash(expectedSender[:]), common.BytesToHash(expectedRecipient[:]), }, log.Topics, ) require.NotEmpty(t, log.Data) - amount, err := UnpackNativeCoinMintedEventData(log.Data) + amount, err := nativeminter.UnpackNativeCoinMintedEventData(log.Data) require.NoError(t, err) require.Zero(t, expectedAmount.Cmp(amount), "expected", expectedAmount, "got", amount) } diff --git a/contracts/contracts/interfaces/INativeMinter.sol b/precompile/contracts/nativeminter/nativemintertest/bindings/INativeMinter.sol similarity index 82% rename from contracts/contracts/interfaces/INativeMinter.sol rename to precompile/contracts/nativeminter/nativemintertest/bindings/INativeMinter.sol index 822f8af86f..7fd63a55c9 100644 --- a/contracts/contracts/interfaces/INativeMinter.sol +++ b/precompile/contracts/nativeminter/nativemintertest/bindings/INativeMinter.sol @@ -1,6 +1,6 @@ //SPDX-License-Identifier: MIT pragma solidity ^0.8.24; -import "./IAllowList.sol"; +import "precompile/allowlist/allowlisttest/bindings/IAllowList.sol"; interface INativeMinter is IAllowList { event NativeCoinMinted(address indexed sender, address indexed recipient, uint256 amount); diff --git a/precompile/contracts/nativeminter/nativemintertest/bindings/NativeMinterTest.sol b/precompile/contracts/nativeminter/nativemintertest/bindings/NativeMinterTest.sol new file mode 100644 index 0000000000..7220cf35b4 --- /dev/null +++ b/precompile/contracts/nativeminter/nativemintertest/bindings/NativeMinterTest.sol @@ -0,0 +1,21 @@ +//SPDX-License-Identifier: MIT +pragma solidity ^0.8.24; + +import "./INativeMinter.sol"; + +contract NativeMinterTest { + INativeMinter private nativeMinter; + + constructor(address nativeMinterPrecompile) { + nativeMinter = INativeMinter(nativeMinterPrecompile); + } + + // Calls the mintNativeCoin function on the precompile + function mintNativeCoin(address addr, uint256 amount) external { + nativeMinter.mintNativeCoin(addr, amount); + } + + // Allows this contract to receive native coins + receive() external payable {} +} + diff --git a/precompile/contracts/nativeminter/nativemintertest/bindings/compile.go b/precompile/contracts/nativeminter/nativemintertest/bindings/compile.go new file mode 100644 index 0000000000..d62e697717 --- /dev/null +++ b/precompile/contracts/nativeminter/nativemintertest/bindings/compile.go @@ -0,0 +1,12 @@ +// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +package bindings + +// Step 1: Compile Solidity contracts to generate ABI and bin files +//go:generate solc-v0.8.30 -o artifacts --overwrite --abi --bin --base-path ../../../../.. precompile/=precompile/ --evm-version cancun NativeMinterTest.sol +// Step 2: Generate Go bindings from the compiled artifacts +//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type INativeMinter --abi artifacts/INativeMinter.abi --bin artifacts/INativeMinter.bin --out gen_inativeminter_binding.go +//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type NativeMinterTest --abi artifacts/NativeMinterTest.abi --bin artifacts/NativeMinterTest.bin --out gen_nativemintertest_binding.go +// Step 3: Replace import paths in generated binding to use subnet-evm instead of libevm +//go:generate sh -c "sed -i.bak -e 's|github.com/ava-labs/libevm/accounts/abi|github.com/ava-labs/subnet-evm/accounts/abi|g' -e 's|github.com/ava-labs/libevm/accounts/abi/bind|github.com/ava-labs/subnet-evm/accounts/abi/bind|g' gen_inativeminter_binding.go gen_nativemintertest_binding.go && rm -f gen_inativeminter_binding.go.bak gen_nativemintertest_binding.go.bak" diff --git a/precompile/contracts/nativeminter/nativemintertest/bindings/gen_inativeminter_binding.go b/precompile/contracts/nativeminter/nativemintertest/bindings/gen_inativeminter_binding.go new file mode 100644 index 0000000000..6a1b88a40e --- /dev/null +++ b/precompile/contracts/nativeminter/nativemintertest/bindings/gen_inativeminter_binding.go @@ -0,0 +1,634 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package bindings + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ava-labs/libevm" + "github.com/ava-labs/subnet-evm/accounts/abi" + "github.com/ava-labs/subnet-evm/accounts/abi/bind" + "github.com/ava-labs/libevm/common" + "github.com/ava-labs/libevm/core/types" + "github.com/ava-labs/libevm/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// INativeMinterMetaData contains all meta data concerning the INativeMinter contract. +var INativeMinterMetaData = &bind.MetaData{ + ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"NativeCoinMinted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"role\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldRole\",\"type\":\"uint256\"}],\"name\":\"RoleSet\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mintNativeCoin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"readAllowList\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"role\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setEnabled\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setNone\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +} + +// INativeMinterABI is the input ABI used to generate the binding from. +// Deprecated: Use INativeMinterMetaData.ABI instead. +var INativeMinterABI = INativeMinterMetaData.ABI + +// INativeMinter is an auto generated Go binding around an Ethereum contract. +type INativeMinter struct { + INativeMinterCaller // Read-only binding to the contract + INativeMinterTransactor // Write-only binding to the contract + INativeMinterFilterer // Log filterer for contract events +} + +// INativeMinterCaller is an auto generated read-only Go binding around an Ethereum contract. +type INativeMinterCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// INativeMinterTransactor is an auto generated write-only Go binding around an Ethereum contract. +type INativeMinterTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// INativeMinterFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type INativeMinterFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// INativeMinterSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type INativeMinterSession struct { + Contract *INativeMinter // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// INativeMinterCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type INativeMinterCallerSession struct { + Contract *INativeMinterCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// INativeMinterTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type INativeMinterTransactorSession struct { + Contract *INativeMinterTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// INativeMinterRaw is an auto generated low-level Go binding around an Ethereum contract. +type INativeMinterRaw struct { + Contract *INativeMinter // Generic contract binding to access the raw methods on +} + +// INativeMinterCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type INativeMinterCallerRaw struct { + Contract *INativeMinterCaller // Generic read-only contract binding to access the raw methods on +} + +// INativeMinterTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type INativeMinterTransactorRaw struct { + Contract *INativeMinterTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewINativeMinter creates a new instance of INativeMinter, bound to a specific deployed contract. +func NewINativeMinter(address common.Address, backend bind.ContractBackend) (*INativeMinter, error) { + contract, err := bindINativeMinter(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &INativeMinter{INativeMinterCaller: INativeMinterCaller{contract: contract}, INativeMinterTransactor: INativeMinterTransactor{contract: contract}, INativeMinterFilterer: INativeMinterFilterer{contract: contract}}, nil +} + +// NewINativeMinterCaller creates a new read-only instance of INativeMinter, bound to a specific deployed contract. +func NewINativeMinterCaller(address common.Address, caller bind.ContractCaller) (*INativeMinterCaller, error) { + contract, err := bindINativeMinter(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &INativeMinterCaller{contract: contract}, nil +} + +// NewINativeMinterTransactor creates a new write-only instance of INativeMinter, bound to a specific deployed contract. +func NewINativeMinterTransactor(address common.Address, transactor bind.ContractTransactor) (*INativeMinterTransactor, error) { + contract, err := bindINativeMinter(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &INativeMinterTransactor{contract: contract}, nil +} + +// NewINativeMinterFilterer creates a new log filterer instance of INativeMinter, bound to a specific deployed contract. +func NewINativeMinterFilterer(address common.Address, filterer bind.ContractFilterer) (*INativeMinterFilterer, error) { + contract, err := bindINativeMinter(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &INativeMinterFilterer{contract: contract}, nil +} + +// bindINativeMinter binds a generic wrapper to an already deployed contract. +func bindINativeMinter(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := INativeMinterMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_INativeMinter *INativeMinterRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _INativeMinter.Contract.INativeMinterCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_INativeMinter *INativeMinterRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _INativeMinter.Contract.INativeMinterTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_INativeMinter *INativeMinterRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _INativeMinter.Contract.INativeMinterTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_INativeMinter *INativeMinterCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _INativeMinter.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_INativeMinter *INativeMinterTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _INativeMinter.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_INativeMinter *INativeMinterTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _INativeMinter.Contract.contract.Transact(opts, method, params...) +} + +// ReadAllowList is a free data retrieval call binding the contract method 0xeb54dae1. +// +// Solidity: function readAllowList(address addr) view returns(uint256 role) +func (_INativeMinter *INativeMinterCaller) ReadAllowList(opts *bind.CallOpts, addr common.Address) (*big.Int, error) { + var out []interface{} + err := _INativeMinter.contract.Call(opts, &out, "readAllowList", addr) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// ReadAllowList is a free data retrieval call binding the contract method 0xeb54dae1. +// +// Solidity: function readAllowList(address addr) view returns(uint256 role) +func (_INativeMinter *INativeMinterSession) ReadAllowList(addr common.Address) (*big.Int, error) { + return _INativeMinter.Contract.ReadAllowList(&_INativeMinter.CallOpts, addr) +} + +// ReadAllowList is a free data retrieval call binding the contract method 0xeb54dae1. +// +// Solidity: function readAllowList(address addr) view returns(uint256 role) +func (_INativeMinter *INativeMinterCallerSession) ReadAllowList(addr common.Address) (*big.Int, error) { + return _INativeMinter.Contract.ReadAllowList(&_INativeMinter.CallOpts, addr) +} + +// MintNativeCoin is a paid mutator transaction binding the contract method 0x4f5aaaba. +// +// Solidity: function mintNativeCoin(address addr, uint256 amount) returns() +func (_INativeMinter *INativeMinterTransactor) MintNativeCoin(opts *bind.TransactOpts, addr common.Address, amount *big.Int) (*types.Transaction, error) { + return _INativeMinter.contract.Transact(opts, "mintNativeCoin", addr, amount) +} + +// MintNativeCoin is a paid mutator transaction binding the contract method 0x4f5aaaba. +// +// Solidity: function mintNativeCoin(address addr, uint256 amount) returns() +func (_INativeMinter *INativeMinterSession) MintNativeCoin(addr common.Address, amount *big.Int) (*types.Transaction, error) { + return _INativeMinter.Contract.MintNativeCoin(&_INativeMinter.TransactOpts, addr, amount) +} + +// MintNativeCoin is a paid mutator transaction binding the contract method 0x4f5aaaba. +// +// Solidity: function mintNativeCoin(address addr, uint256 amount) returns() +func (_INativeMinter *INativeMinterTransactorSession) MintNativeCoin(addr common.Address, amount *big.Int) (*types.Transaction, error) { + return _INativeMinter.Contract.MintNativeCoin(&_INativeMinter.TransactOpts, addr, amount) +} + +// SetAdmin is a paid mutator transaction binding the contract method 0x704b6c02. +// +// Solidity: function setAdmin(address addr) returns() +func (_INativeMinter *INativeMinterTransactor) SetAdmin(opts *bind.TransactOpts, addr common.Address) (*types.Transaction, error) { + return _INativeMinter.contract.Transact(opts, "setAdmin", addr) +} + +// SetAdmin is a paid mutator transaction binding the contract method 0x704b6c02. +// +// Solidity: function setAdmin(address addr) returns() +func (_INativeMinter *INativeMinterSession) SetAdmin(addr common.Address) (*types.Transaction, error) { + return _INativeMinter.Contract.SetAdmin(&_INativeMinter.TransactOpts, addr) +} + +// SetAdmin is a paid mutator transaction binding the contract method 0x704b6c02. +// +// Solidity: function setAdmin(address addr) returns() +func (_INativeMinter *INativeMinterTransactorSession) SetAdmin(addr common.Address) (*types.Transaction, error) { + return _INativeMinter.Contract.SetAdmin(&_INativeMinter.TransactOpts, addr) +} + +// SetEnabled is a paid mutator transaction binding the contract method 0x0aaf7043. +// +// Solidity: function setEnabled(address addr) returns() +func (_INativeMinter *INativeMinterTransactor) SetEnabled(opts *bind.TransactOpts, addr common.Address) (*types.Transaction, error) { + return _INativeMinter.contract.Transact(opts, "setEnabled", addr) +} + +// SetEnabled is a paid mutator transaction binding the contract method 0x0aaf7043. +// +// Solidity: function setEnabled(address addr) returns() +func (_INativeMinter *INativeMinterSession) SetEnabled(addr common.Address) (*types.Transaction, error) { + return _INativeMinter.Contract.SetEnabled(&_INativeMinter.TransactOpts, addr) +} + +// SetEnabled is a paid mutator transaction binding the contract method 0x0aaf7043. +// +// Solidity: function setEnabled(address addr) returns() +func (_INativeMinter *INativeMinterTransactorSession) SetEnabled(addr common.Address) (*types.Transaction, error) { + return _INativeMinter.Contract.SetEnabled(&_INativeMinter.TransactOpts, addr) +} + +// SetManager is a paid mutator transaction binding the contract method 0xd0ebdbe7. +// +// Solidity: function setManager(address addr) returns() +func (_INativeMinter *INativeMinterTransactor) SetManager(opts *bind.TransactOpts, addr common.Address) (*types.Transaction, error) { + return _INativeMinter.contract.Transact(opts, "setManager", addr) +} + +// SetManager is a paid mutator transaction binding the contract method 0xd0ebdbe7. +// +// Solidity: function setManager(address addr) returns() +func (_INativeMinter *INativeMinterSession) SetManager(addr common.Address) (*types.Transaction, error) { + return _INativeMinter.Contract.SetManager(&_INativeMinter.TransactOpts, addr) +} + +// SetManager is a paid mutator transaction binding the contract method 0xd0ebdbe7. +// +// Solidity: function setManager(address addr) returns() +func (_INativeMinter *INativeMinterTransactorSession) SetManager(addr common.Address) (*types.Transaction, error) { + return _INativeMinter.Contract.SetManager(&_INativeMinter.TransactOpts, addr) +} + +// SetNone is a paid mutator transaction binding the contract method 0x8c6bfb3b. +// +// Solidity: function setNone(address addr) returns() +func (_INativeMinter *INativeMinterTransactor) SetNone(opts *bind.TransactOpts, addr common.Address) (*types.Transaction, error) { + return _INativeMinter.contract.Transact(opts, "setNone", addr) +} + +// SetNone is a paid mutator transaction binding the contract method 0x8c6bfb3b. +// +// Solidity: function setNone(address addr) returns() +func (_INativeMinter *INativeMinterSession) SetNone(addr common.Address) (*types.Transaction, error) { + return _INativeMinter.Contract.SetNone(&_INativeMinter.TransactOpts, addr) +} + +// SetNone is a paid mutator transaction binding the contract method 0x8c6bfb3b. +// +// Solidity: function setNone(address addr) returns() +func (_INativeMinter *INativeMinterTransactorSession) SetNone(addr common.Address) (*types.Transaction, error) { + return _INativeMinter.Contract.SetNone(&_INativeMinter.TransactOpts, addr) +} + +// INativeMinterNativeCoinMintedIterator is returned from FilterNativeCoinMinted and is used to iterate over the raw logs and unpacked data for NativeCoinMinted events raised by the INativeMinter contract. +type INativeMinterNativeCoinMintedIterator struct { + Event *INativeMinterNativeCoinMinted // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *INativeMinterNativeCoinMintedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(INativeMinterNativeCoinMinted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(INativeMinterNativeCoinMinted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *INativeMinterNativeCoinMintedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *INativeMinterNativeCoinMintedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// INativeMinterNativeCoinMinted represents a NativeCoinMinted event raised by the INativeMinter contract. +type INativeMinterNativeCoinMinted struct { + Sender common.Address + Recipient common.Address + Amount *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterNativeCoinMinted is a free log retrieval operation binding the contract event 0x400cd392f3d56fd10bb1dbd5839fdda8298208ddaa97b368faa053e1850930ee. +// +// Solidity: event NativeCoinMinted(address indexed sender, address indexed recipient, uint256 amount) +func (_INativeMinter *INativeMinterFilterer) FilterNativeCoinMinted(opts *bind.FilterOpts, sender []common.Address, recipient []common.Address) (*INativeMinterNativeCoinMintedIterator, error) { + + var senderRule []interface{} + for _, senderItem := range sender { + senderRule = append(senderRule, senderItem) + } + var recipientRule []interface{} + for _, recipientItem := range recipient { + recipientRule = append(recipientRule, recipientItem) + } + + logs, sub, err := _INativeMinter.contract.FilterLogs(opts, "NativeCoinMinted", senderRule, recipientRule) + if err != nil { + return nil, err + } + return &INativeMinterNativeCoinMintedIterator{contract: _INativeMinter.contract, event: "NativeCoinMinted", logs: logs, sub: sub}, nil +} + +// WatchNativeCoinMinted is a free log subscription operation binding the contract event 0x400cd392f3d56fd10bb1dbd5839fdda8298208ddaa97b368faa053e1850930ee. +// +// Solidity: event NativeCoinMinted(address indexed sender, address indexed recipient, uint256 amount) +func (_INativeMinter *INativeMinterFilterer) WatchNativeCoinMinted(opts *bind.WatchOpts, sink chan<- *INativeMinterNativeCoinMinted, sender []common.Address, recipient []common.Address) (event.Subscription, error) { + + var senderRule []interface{} + for _, senderItem := range sender { + senderRule = append(senderRule, senderItem) + } + var recipientRule []interface{} + for _, recipientItem := range recipient { + recipientRule = append(recipientRule, recipientItem) + } + + logs, sub, err := _INativeMinter.contract.WatchLogs(opts, "NativeCoinMinted", senderRule, recipientRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(INativeMinterNativeCoinMinted) + if err := _INativeMinter.contract.UnpackLog(event, "NativeCoinMinted", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseNativeCoinMinted is a log parse operation binding the contract event 0x400cd392f3d56fd10bb1dbd5839fdda8298208ddaa97b368faa053e1850930ee. +// +// Solidity: event NativeCoinMinted(address indexed sender, address indexed recipient, uint256 amount) +func (_INativeMinter *INativeMinterFilterer) ParseNativeCoinMinted(log types.Log) (*INativeMinterNativeCoinMinted, error) { + event := new(INativeMinterNativeCoinMinted) + if err := _INativeMinter.contract.UnpackLog(event, "NativeCoinMinted", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// INativeMinterRoleSetIterator is returned from FilterRoleSet and is used to iterate over the raw logs and unpacked data for RoleSet events raised by the INativeMinter contract. +type INativeMinterRoleSetIterator struct { + Event *INativeMinterRoleSet // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *INativeMinterRoleSetIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(INativeMinterRoleSet) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(INativeMinterRoleSet) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *INativeMinterRoleSetIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *INativeMinterRoleSetIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// INativeMinterRoleSet represents a RoleSet event raised by the INativeMinter contract. +type INativeMinterRoleSet struct { + Role *big.Int + Account common.Address + Sender common.Address + OldRole *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterRoleSet is a free log retrieval operation binding the contract event 0xcdb7ea01f00a414d78757bdb0f6391664ba3fedf987eed280927c1e7d695be3e. +// +// Solidity: event RoleSet(uint256 indexed role, address indexed account, address indexed sender, uint256 oldRole) +func (_INativeMinter *INativeMinterFilterer) FilterRoleSet(opts *bind.FilterOpts, role []*big.Int, account []common.Address, sender []common.Address) (*INativeMinterRoleSetIterator, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var accountRule []interface{} + for _, accountItem := range account { + accountRule = append(accountRule, accountItem) + } + var senderRule []interface{} + for _, senderItem := range sender { + senderRule = append(senderRule, senderItem) + } + + logs, sub, err := _INativeMinter.contract.FilterLogs(opts, "RoleSet", roleRule, accountRule, senderRule) + if err != nil { + return nil, err + } + return &INativeMinterRoleSetIterator{contract: _INativeMinter.contract, event: "RoleSet", logs: logs, sub: sub}, nil +} + +// WatchRoleSet is a free log subscription operation binding the contract event 0xcdb7ea01f00a414d78757bdb0f6391664ba3fedf987eed280927c1e7d695be3e. +// +// Solidity: event RoleSet(uint256 indexed role, address indexed account, address indexed sender, uint256 oldRole) +func (_INativeMinter *INativeMinterFilterer) WatchRoleSet(opts *bind.WatchOpts, sink chan<- *INativeMinterRoleSet, role []*big.Int, account []common.Address, sender []common.Address) (event.Subscription, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var accountRule []interface{} + for _, accountItem := range account { + accountRule = append(accountRule, accountItem) + } + var senderRule []interface{} + for _, senderItem := range sender { + senderRule = append(senderRule, senderItem) + } + + logs, sub, err := _INativeMinter.contract.WatchLogs(opts, "RoleSet", roleRule, accountRule, senderRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(INativeMinterRoleSet) + if err := _INativeMinter.contract.UnpackLog(event, "RoleSet", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseRoleSet is a log parse operation binding the contract event 0xcdb7ea01f00a414d78757bdb0f6391664ba3fedf987eed280927c1e7d695be3e. +// +// Solidity: event RoleSet(uint256 indexed role, address indexed account, address indexed sender, uint256 oldRole) +func (_INativeMinter *INativeMinterFilterer) ParseRoleSet(log types.Log) (*INativeMinterRoleSet, error) { + event := new(INativeMinterRoleSet) + if err := _INativeMinter.contract.UnpackLog(event, "RoleSet", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/precompile/contracts/nativeminter/nativemintertest/bindings/gen_nativemintertest_binding.go b/precompile/contracts/nativeminter/nativemintertest/bindings/gen_nativemintertest_binding.go new file mode 100644 index 0000000000..696d206166 --- /dev/null +++ b/precompile/contracts/nativeminter/nativemintertest/bindings/gen_nativemintertest_binding.go @@ -0,0 +1,245 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package bindings + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ava-labs/libevm" + "github.com/ava-labs/subnet-evm/accounts/abi" + "github.com/ava-labs/subnet-evm/accounts/abi/bind" + "github.com/ava-labs/libevm/common" + "github.com/ava-labs/libevm/core/types" + "github.com/ava-labs/libevm/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// NativeMinterTestMetaData contains all meta data concerning the NativeMinterTest contract. +var NativeMinterTestMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeMinterPrecompile\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mintNativeCoin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", + Bin: "0x608060405234801561000f575f5ffd5b50604051610336380380610336833981810160405281019061003191906100d4565b805f5f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506100ff565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100a38261007a565b9050919050565b6100b381610099565b81146100bd575f5ffd5b50565b5f815190506100ce816100aa565b92915050565b5f602082840312156100e9576100e8610076565b5b5f6100f6848285016100c0565b91505092915050565b61022a8061010c5f395ff3fe608060405260043610610021575f3560e01c80634f5aaaba1461002c57610028565b3661002857005b5f5ffd5b348015610037575f5ffd5b50610052600480360381019061004d9190610171565b610054565b005b5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16634f5aaaba83836040518363ffffffff1660e01b81526004016100af9291906101cd565b5f604051808303815f87803b1580156100c6575f5ffd5b505af11580156100d8573d5f5f3e3d5ffd5b505050505050565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61010d826100e4565b9050919050565b61011d81610103565b8114610127575f5ffd5b50565b5f8135905061013881610114565b92915050565b5f819050919050565b6101508161013e565b811461015a575f5ffd5b50565b5f8135905061016b81610147565b92915050565b5f5f60408385031215610187576101866100e0565b5b5f6101948582860161012a565b92505060206101a58582860161015d565b9150509250929050565b6101b881610103565b82525050565b6101c78161013e565b82525050565b5f6040820190506101e05f8301856101af565b6101ed60208301846101be565b939250505056fea264697066735822122022a495ab74b25db78e2d373ef8499eee646e53fb4eb515ac693575252359c1ae64736f6c634300081e0033", +} + +// NativeMinterTestABI is the input ABI used to generate the binding from. +// Deprecated: Use NativeMinterTestMetaData.ABI instead. +var NativeMinterTestABI = NativeMinterTestMetaData.ABI + +// NativeMinterTestBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use NativeMinterTestMetaData.Bin instead. +var NativeMinterTestBin = NativeMinterTestMetaData.Bin + +// DeployNativeMinterTest deploys a new Ethereum contract, binding an instance of NativeMinterTest to it. +func DeployNativeMinterTest(auth *bind.TransactOpts, backend bind.ContractBackend, nativeMinterPrecompile common.Address) (common.Address, *types.Transaction, *NativeMinterTest, error) { + parsed, err := NativeMinterTestMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(NativeMinterTestBin), backend, nativeMinterPrecompile) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &NativeMinterTest{NativeMinterTestCaller: NativeMinterTestCaller{contract: contract}, NativeMinterTestTransactor: NativeMinterTestTransactor{contract: contract}, NativeMinterTestFilterer: NativeMinterTestFilterer{contract: contract}}, nil +} + +// NativeMinterTest is an auto generated Go binding around an Ethereum contract. +type NativeMinterTest struct { + NativeMinterTestCaller // Read-only binding to the contract + NativeMinterTestTransactor // Write-only binding to the contract + NativeMinterTestFilterer // Log filterer for contract events +} + +// NativeMinterTestCaller is an auto generated read-only Go binding around an Ethereum contract. +type NativeMinterTestCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// NativeMinterTestTransactor is an auto generated write-only Go binding around an Ethereum contract. +type NativeMinterTestTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// NativeMinterTestFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type NativeMinterTestFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// NativeMinterTestSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type NativeMinterTestSession struct { + Contract *NativeMinterTest // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// NativeMinterTestCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type NativeMinterTestCallerSession struct { + Contract *NativeMinterTestCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// NativeMinterTestTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type NativeMinterTestTransactorSession struct { + Contract *NativeMinterTestTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// NativeMinterTestRaw is an auto generated low-level Go binding around an Ethereum contract. +type NativeMinterTestRaw struct { + Contract *NativeMinterTest // Generic contract binding to access the raw methods on +} + +// NativeMinterTestCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type NativeMinterTestCallerRaw struct { + Contract *NativeMinterTestCaller // Generic read-only contract binding to access the raw methods on +} + +// NativeMinterTestTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type NativeMinterTestTransactorRaw struct { + Contract *NativeMinterTestTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewNativeMinterTest creates a new instance of NativeMinterTest, bound to a specific deployed contract. +func NewNativeMinterTest(address common.Address, backend bind.ContractBackend) (*NativeMinterTest, error) { + contract, err := bindNativeMinterTest(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &NativeMinterTest{NativeMinterTestCaller: NativeMinterTestCaller{contract: contract}, NativeMinterTestTransactor: NativeMinterTestTransactor{contract: contract}, NativeMinterTestFilterer: NativeMinterTestFilterer{contract: contract}}, nil +} + +// NewNativeMinterTestCaller creates a new read-only instance of NativeMinterTest, bound to a specific deployed contract. +func NewNativeMinterTestCaller(address common.Address, caller bind.ContractCaller) (*NativeMinterTestCaller, error) { + contract, err := bindNativeMinterTest(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &NativeMinterTestCaller{contract: contract}, nil +} + +// NewNativeMinterTestTransactor creates a new write-only instance of NativeMinterTest, bound to a specific deployed contract. +func NewNativeMinterTestTransactor(address common.Address, transactor bind.ContractTransactor) (*NativeMinterTestTransactor, error) { + contract, err := bindNativeMinterTest(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &NativeMinterTestTransactor{contract: contract}, nil +} + +// NewNativeMinterTestFilterer creates a new log filterer instance of NativeMinterTest, bound to a specific deployed contract. +func NewNativeMinterTestFilterer(address common.Address, filterer bind.ContractFilterer) (*NativeMinterTestFilterer, error) { + contract, err := bindNativeMinterTest(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &NativeMinterTestFilterer{contract: contract}, nil +} + +// bindNativeMinterTest binds a generic wrapper to an already deployed contract. +func bindNativeMinterTest(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := NativeMinterTestMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_NativeMinterTest *NativeMinterTestRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _NativeMinterTest.Contract.NativeMinterTestCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_NativeMinterTest *NativeMinterTestRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _NativeMinterTest.Contract.NativeMinterTestTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_NativeMinterTest *NativeMinterTestRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _NativeMinterTest.Contract.NativeMinterTestTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_NativeMinterTest *NativeMinterTestCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _NativeMinterTest.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_NativeMinterTest *NativeMinterTestTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _NativeMinterTest.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_NativeMinterTest *NativeMinterTestTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _NativeMinterTest.Contract.contract.Transact(opts, method, params...) +} + +// MintNativeCoin is a paid mutator transaction binding the contract method 0x4f5aaaba. +// +// Solidity: function mintNativeCoin(address addr, uint256 amount) returns() +func (_NativeMinterTest *NativeMinterTestTransactor) MintNativeCoin(opts *bind.TransactOpts, addr common.Address, amount *big.Int) (*types.Transaction, error) { + return _NativeMinterTest.contract.Transact(opts, "mintNativeCoin", addr, amount) +} + +// MintNativeCoin is a paid mutator transaction binding the contract method 0x4f5aaaba. +// +// Solidity: function mintNativeCoin(address addr, uint256 amount) returns() +func (_NativeMinterTest *NativeMinterTestSession) MintNativeCoin(addr common.Address, amount *big.Int) (*types.Transaction, error) { + return _NativeMinterTest.Contract.MintNativeCoin(&_NativeMinterTest.TransactOpts, addr, amount) +} + +// MintNativeCoin is a paid mutator transaction binding the contract method 0x4f5aaaba. +// +// Solidity: function mintNativeCoin(address addr, uint256 amount) returns() +func (_NativeMinterTest *NativeMinterTestTransactorSession) MintNativeCoin(addr common.Address, amount *big.Int) (*types.Transaction, error) { + return _NativeMinterTest.Contract.MintNativeCoin(&_NativeMinterTest.TransactOpts, addr, amount) +} + +// Receive is a paid mutator transaction binding the contract receive function. +// +// Solidity: receive() payable returns() +func (_NativeMinterTest *NativeMinterTestTransactor) Receive(opts *bind.TransactOpts) (*types.Transaction, error) { + return _NativeMinterTest.contract.RawTransact(opts, nil) // calldata is disallowed for receive function +} + +// Receive is a paid mutator transaction binding the contract receive function. +// +// Solidity: receive() payable returns() +func (_NativeMinterTest *NativeMinterTestSession) Receive() (*types.Transaction, error) { + return _NativeMinterTest.Contract.Receive(&_NativeMinterTest.TransactOpts) +} + +// Receive is a paid mutator transaction binding the contract receive function. +// +// Solidity: receive() payable returns() +func (_NativeMinterTest *NativeMinterTestTransactorSession) Receive() (*types.Transaction, error) { + return _NativeMinterTest.Contract.Receive(&_NativeMinterTest.TransactOpts) +} diff --git a/precompile/contracts/nativeminter/simulated_test.go b/precompile/contracts/nativeminter/simulated_test.go new file mode 100644 index 0000000000..5560d82e97 --- /dev/null +++ b/precompile/contracts/nativeminter/simulated_test.go @@ -0,0 +1,222 @@ +// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +package nativeminter_test + +import ( + "math/big" + "testing" + + "github.com/ava-labs/libevm/common" + "github.com/ava-labs/libevm/core/types" + "github.com/ava-labs/libevm/core/vm" + "github.com/ava-labs/libevm/crypto" + "github.com/stretchr/testify/require" + + "github.com/ava-labs/subnet-evm/accounts/abi/bind" + "github.com/ava-labs/subnet-evm/core" + "github.com/ava-labs/subnet-evm/params" + "github.com/ava-labs/subnet-evm/params/extras" + "github.com/ava-labs/subnet-evm/plugin/evm/customtypes" + "github.com/ava-labs/subnet-evm/precompile/allowlist" + "github.com/ava-labs/subnet-evm/precompile/allowlist/allowlisttest" + "github.com/ava-labs/subnet-evm/precompile/contracts/nativeminter" + "github.com/ava-labs/subnet-evm/precompile/contracts/testutils" + "github.com/ava-labs/subnet-evm/utils" + + sim "github.com/ava-labs/subnet-evm/ethclient/simulated" + nativeminterbindings "github.com/ava-labs/subnet-evm/precompile/contracts/nativeminter/nativemintertest/bindings" +) + +var ( + adminKey, _ = crypto.GenerateKey() + unprivilegedKey, _ = crypto.GenerateKey() + + adminAddress = crypto.PubkeyToAddress(adminKey.PublicKey) + unprivilegedAddress = crypto.PubkeyToAddress(unprivilegedKey.PublicKey) +) + +func TestMain(m *testing.M) { + // Ensure libevm extras are registered for tests. + core.RegisterExtras() + customtypes.Register() + params.RegisterExtras() + m.Run() +} + +func newBackendWithNativeMinter(t *testing.T) *sim.Backend { + t.Helper() + chainCfg := params.Copy(params.TestChainConfig) + + // Enable ContractNativeMinter at genesis with admin set to adminAddress. + params.GetExtra(&chainCfg).GenesisPrecompiles = extras.Precompiles{ + nativeminter.ConfigKey: nativeminter.NewConfig(utils.NewUint64(0), []common.Address{adminAddress}, nil, nil, nil), + } + return sim.NewBackend( + types.GenesisAlloc{ + adminAddress: {Balance: big.NewInt(1000000000000000000)}, + unprivilegedAddress: {Balance: big.NewInt(1000000000000000000)}, + }, + sim.WithChainConfig(&chainCfg), + ) +} + +// Helper functions to reduce test boilerplate + +func deployNativeMinterTest(t *testing.T, b *sim.Backend, auth *bind.TransactOpts) (common.Address, *nativeminterbindings.NativeMinterTest) { + t.Helper() + addr, tx, contract, err := nativeminterbindings.DeployNativeMinterTest(auth, b.Client(), nativeminter.ContractAddress) + require.NoError(t, err) + testutils.WaitReceiptSuccessful(t, b, tx) + return addr, contract +} + +func TestNativeMinter(t *testing.T) { + chainID := params.TestChainConfig.ChainID + admin := testutils.NewAuth(t, adminKey, chainID) + unprivileged := testutils.NewAuth(t, unprivilegedKey, chainID) + + amount := big.NewInt(100) + + type testCase struct { + name string + test func(t *testing.T, backend *sim.Backend, nativeMinterIntf *nativeminterbindings.INativeMinter) + } + + testCases := []testCase{ + { + name: "admin can mint directly", + test: func(t *testing.T, backend *sim.Backend, nativeMinter *nativeminterbindings.INativeMinter) { + testAddr := common.HexToAddress("0x1234567890123456789012345678901234567890") + + initialBalance, err := backend.Client().BalanceAt(t.Context(), testAddr, nil) + require.NoError(t, err) + + // Admin mints native coins directly to testAddr + tx, err := nativeMinter.MintNativeCoin(admin, testAddr, amount) + require.NoError(t, err) + testutils.WaitReceiptSuccessful(t, backend, tx) + + // Verify balance increased + finalBalance, err := backend.Client().BalanceAt(t.Context(), testAddr, nil) + require.NoError(t, err) + expectedBalance := new(big.Int).Add(initialBalance, amount) + require.Zero(t, expectedBalance.Cmp(finalBalance), "balance should have increased by amount") + }, + }, + { + name: "unprivileged user cannot mint directly", + test: func(t *testing.T, _ *sim.Backend, nativeMinter *nativeminterbindings.INativeMinter) { + testAddr := common.HexToAddress("0x1234567890123456789012345678901234567890") + + // Unprivileged user tries to mint - should fail + _, err := nativeMinter.MintNativeCoin(unprivileged, testAddr, amount) + require.Error(t, err) + }, + }, + { + name: "contract without permission cannot mint", + test: func(t *testing.T, backend *sim.Backend, nativeMinter *nativeminterbindings.INativeMinter) { + testContractAddr, testContract := deployNativeMinterTest(t, backend, admin) + + allowlisttest.VerifyRole(t, nativeMinter, testContractAddr, allowlist.NoRole) + + testAddr := common.HexToAddress("0x1234567890123456789012345678901234567890") + + // Contract tries to mint and then should revert because it's not enabled + _, err := testContract.MintNativeCoin(admin, testAddr, amount) + require.ErrorContains(t, err, vm.ErrExecutionReverted.Error()) + }, + }, + { + name: "contract can be added to allow list", + test: func(t *testing.T, backend *sim.Backend, nativeMinter *nativeminterbindings.INativeMinter) { + testContractAddr, _ := deployNativeMinterTest(t, backend, admin) + + allowlisttest.VerifyRole(t, nativeMinter, testContractAddr, allowlist.NoRole) + + allowlisttest.SetAsEnabled(t, backend, nativeMinter, admin, testContractAddr) + + allowlisttest.VerifyRole(t, nativeMinter, testContractAddr, allowlist.EnabledRole) + }, + }, + { + name: "enabled contract can mint", + test: func(t *testing.T, backend *sim.Backend, nativeMinter *nativeminterbindings.INativeMinter) { + testContractAddr, testContract := deployNativeMinterTest(t, backend, admin) + testAddr := common.HexToAddress("0x1234567890123456789012345678901234567890") + + allowlisttest.SetAsEnabled(t, backend, nativeMinter, admin, testContractAddr) + + initialBalance, err := backend.Client().BalanceAt(t.Context(), testAddr, nil) + require.NoError(t, err) + + // Enabled contract mints native coins + tx, err := testContract.MintNativeCoin(admin, testAddr, amount) + require.NoError(t, err) + testutils.WaitReceiptSuccessful(t, backend, tx) + + // Verify balance increased + finalBalance, err := backend.Client().BalanceAt(t.Context(), testAddr, nil) + require.NoError(t, err) + expectedBalance := new(big.Int).Add(initialBalance, amount) + require.Zero(t, expectedBalance.Cmp(finalBalance), "balance should have increased by amount") + }, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + backend := newBackendWithNativeMinter(t) + defer backend.Close() + + nativeMinter, err := nativeminterbindings.NewINativeMinter(nativeminter.ContractAddress, backend.Client()) + require.NoError(t, err) + + tc.test(t, backend, nativeMinter) + }) + } +} + +func TestINativeMinter_Events(t *testing.T) { + chainID := params.TestChainConfig.ChainID + admin := testutils.NewAuth(t, adminKey, chainID) + testKey, _ := crypto.GenerateKey() + testAddress := crypto.PubkeyToAddress(testKey.PublicKey) + + backend := newBackendWithNativeMinter(t) + defer backend.Close() + + nativeMinter, err := nativeminterbindings.NewINativeMinter(nativeminter.ContractAddress, backend.Client()) + require.NoError(t, err) + + t.Run("should emit NativeCoinMinted event", func(t *testing.T) { + require := require.New(t) + + amount := big.NewInt(1000) + + tx, err := nativeMinter.MintNativeCoin(admin, testAddress, amount) + require.NoError(err) + testutils.WaitReceiptSuccessful(t, backend, tx) + + // Filter for NativeCoinMinted events + iter, err := nativeMinter.FilterNativeCoinMinted( + nil, + []common.Address{adminAddress}, + []common.Address{testAddress}, + ) + require.NoError(err) + defer iter.Close() + + // Verify event fields match expected values + require.True(iter.Next(), "expected to find NativeCoinMinted event") + event := iter.Event + require.Equal(adminAddress, event.Sender) + require.Equal(testAddress, event.Recipient) + require.Zero(amount.Cmp(event.Amount), "amount mismatch") + + // Verify there are no more events + require.False(iter.Next(), "expected no more NativeCoinMinted events") + require.NoError(iter.Error()) + }) +} diff --git a/precompile/contracts/rewardmanager/config_test.go b/precompile/contracts/rewardmanager/config_test.go index 7c0b8beaab..201b97e2f7 100644 --- a/precompile/contracts/rewardmanager/config_test.go +++ b/precompile/contracts/rewardmanager/config_test.go @@ -1,7 +1,7 @@ // Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package rewardmanager +package rewardmanager_test import ( "testing" @@ -10,6 +10,7 @@ import ( "go.uber.org/mock/gomock" "github.com/ava-labs/subnet-evm/precompile/allowlist/allowlisttest" + "github.com/ava-labs/subnet-evm/precompile/contracts/rewardmanager" "github.com/ava-labs/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/subnet-evm/precompile/precompiletest" "github.com/ava-labs/subnet-evm/utils" @@ -21,14 +22,14 @@ func TestVerify(t *testing.T) { managers := []common.Address{allowlisttest.TestManagerAddr} tests := map[string]precompiletest.ConfigVerifyTest{ "both reward mechanisms should not be activated at the same time in reward manager": { - Config: NewConfig(utils.NewUint64(3), admins, enableds, managers, &InitialRewardConfig{ + Config: rewardmanager.NewConfig(utils.NewUint64(3), admins, enableds, managers, &rewardmanager.InitialRewardConfig{ AllowFeeRecipients: true, RewardAddress: common.HexToAddress("0x01"), }), - ExpectedError: ErrCannotEnableBothRewards.Error(), + ExpectedError: rewardmanager.ErrCannotEnableBothRewards.Error(), }, } - allowlisttest.VerifyPrecompileWithAllowListTests(t, Module, tests) + allowlisttest.VerifyPrecompileWithAllowListTests(t, rewardmanager.Module, tests) } func TestEqual(t *testing.T) { @@ -37,46 +38,46 @@ func TestEqual(t *testing.T) { managers := []common.Address{allowlisttest.TestManagerAddr} tests := map[string]precompiletest.ConfigEqualTest{ "non-nil config and nil other": { - Config: NewConfig(utils.NewUint64(3), admins, enableds, managers, nil), + Config: rewardmanager.NewConfig(utils.NewUint64(3), admins, enableds, managers, nil), Other: nil, Expected: false, }, "different type": { - Config: NewConfig(utils.NewUint64(3), admins, enableds, managers, nil), + Config: rewardmanager.NewConfig(utils.NewUint64(3), admins, enableds, managers, nil), Other: precompileconfig.NewMockConfig(gomock.NewController(t)), Expected: false, }, "different timestamp": { - Config: NewConfig(utils.NewUint64(3), admins, nil, nil, nil), - Other: NewConfig(utils.NewUint64(4), admins, nil, nil, nil), + Config: rewardmanager.NewConfig(utils.NewUint64(3), admins, nil, nil, nil), + Other: rewardmanager.NewConfig(utils.NewUint64(4), admins, nil, nil, nil), Expected: false, }, "non-nil initial config and nil initial config": { - Config: NewConfig(utils.NewUint64(3), admins, nil, nil, &InitialRewardConfig{ + Config: rewardmanager.NewConfig(utils.NewUint64(3), admins, nil, nil, &rewardmanager.InitialRewardConfig{ AllowFeeRecipients: true, }), - Other: NewConfig(utils.NewUint64(3), admins, nil, nil, nil), + Other: rewardmanager.NewConfig(utils.NewUint64(3), admins, nil, nil, nil), Expected: false, }, "different initial config": { - Config: NewConfig(utils.NewUint64(3), admins, nil, nil, &InitialRewardConfig{ + Config: rewardmanager.NewConfig(utils.NewUint64(3), admins, nil, nil, &rewardmanager.InitialRewardConfig{ RewardAddress: common.HexToAddress("0x01"), }), - Other: NewConfig(utils.NewUint64(3), admins, nil, nil, - &InitialRewardConfig{ + Other: rewardmanager.NewConfig(utils.NewUint64(3), admins, nil, nil, + &rewardmanager.InitialRewardConfig{ RewardAddress: common.HexToAddress("0x02"), }), Expected: false, }, "same config": { - Config: NewConfig(utils.NewUint64(3), admins, nil, nil, &InitialRewardConfig{ + Config: rewardmanager.NewConfig(utils.NewUint64(3), admins, nil, nil, &rewardmanager.InitialRewardConfig{ RewardAddress: common.HexToAddress("0x01"), }), - Other: NewConfig(utils.NewUint64(3), admins, nil, nil, &InitialRewardConfig{ + Other: rewardmanager.NewConfig(utils.NewUint64(3), admins, nil, nil, &rewardmanager.InitialRewardConfig{ RewardAddress: common.HexToAddress("0x01"), }), Expected: true, }, } - allowlisttest.EqualPrecompileWithAllowListTests(t, Module, tests) + allowlisttest.EqualPrecompileWithAllowListTests(t, rewardmanager.Module, tests) } diff --git a/precompile/contracts/rewardmanager/contract_test.go b/precompile/contracts/rewardmanager/contract_test.go index 0d932d40f6..39852eb751 100644 --- a/precompile/contracts/rewardmanager/contract_test.go +++ b/precompile/contracts/rewardmanager/contract_test.go @@ -1,7 +1,7 @@ // Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package rewardmanager +package rewardmanager_test import ( "testing" @@ -15,6 +15,7 @@ import ( "github.com/ava-labs/subnet-evm/constants" "github.com/ava-labs/subnet-evm/core/extstate" "github.com/ava-labs/subnet-evm/precompile/allowlist/allowlisttest" + "github.com/ava-labs/subnet-evm/precompile/contracts/rewardmanager" "github.com/ava-labs/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/subnet-evm/precompile/precompiletest" @@ -27,60 +28,60 @@ var ( { Name: "set_allow_fee_recipients_from_no_role_fails", Caller: allowlisttest.TestNoRoleAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(rewardmanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackAllowFeeRecipients() + input, err := rewardmanager.PackAllowFeeRecipients() require.NoError(t, err) return input }, - SuppliedGas: AllowFeeRecipientsGasCost, + SuppliedGas: rewardmanager.AllowFeeRecipientsGasCost, ReadOnly: false, - ExpectedErr: ErrCannotAllowFeeRecipients.Error(), + ExpectedErr: rewardmanager.ErrCannotAllowFeeRecipients.Error(), }, { Name: "set_reward_address_from_no_role_fails", Caller: allowlisttest.TestNoRoleAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(rewardmanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackSetRewardAddress(rewardAddress) + input, err := rewardmanager.PackSetRewardAddress(rewardAddress) require.NoError(t, err) return input }, - SuppliedGas: SetRewardAddressGasCost, + SuppliedGas: rewardmanager.SetRewardAddressGasCost, ReadOnly: false, - ExpectedErr: ErrCannotSetRewardAddress.Error(), + ExpectedErr: rewardmanager.ErrCannotSetRewardAddress.Error(), }, { Name: "disable_rewards_from_no_role_fails", Caller: allowlisttest.TestNoRoleAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(rewardmanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackDisableRewards() + input, err := rewardmanager.PackDisableRewards() require.NoError(t, err) return input }, - SuppliedGas: DisableRewardsGasCost, + SuppliedGas: rewardmanager.DisableRewardsGasCost, ReadOnly: false, - ExpectedErr: ErrCannotDisableRewards.Error(), + ExpectedErr: rewardmanager.ErrCannotDisableRewards.Error(), }, { Name: "set_allow_fee_recipients_from_enabled_succeeds", Caller: allowlisttest.TestEnabledAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(rewardmanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackAllowFeeRecipients() + input, err := rewardmanager.PackAllowFeeRecipients() require.NoError(t, err) return input }, - SuppliedGas: AllowFeeRecipientsGasCost + FeeRecipientsAllowedEventGasCost, + SuppliedGas: rewardmanager.AllowFeeRecipientsGasCost + rewardmanager.FeeRecipientsAllowedEventGasCost, ReadOnly: false, ExpectedRes: []byte{}, AfterHook: func(t testing.TB, state *extstate.StateDB) { - _, isFeeRecipients := GetStoredRewardAddress(state) + _, isFeeRecipients := rewardmanager.GetStoredRewardAddress(state) require.True(t, isFeeRecipients) logs := state.Logs() @@ -90,9 +91,9 @@ var ( { Name: "set_fee_recipients_should_not_emit_events_pre_Durango", Caller: allowlisttest.TestEnabledAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(rewardmanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackAllowFeeRecipients() + input, err := rewardmanager.PackAllowFeeRecipients() require.NoError(t, err) return input @@ -104,7 +105,7 @@ var ( mockChainConfig.EXPECT().IsDurango(gomock.Any()).AnyTimes().Return(false) return mockChainConfig }, - SuppliedGas: AllowFeeRecipientsGasCost, + SuppliedGas: rewardmanager.AllowFeeRecipientsGasCost, ReadOnly: false, ExpectedRes: []byte{}, AfterHook: func(t testing.TB, stateDB *extstate.StateDB) { @@ -116,18 +117,18 @@ var ( { Name: "set_reward_address_from_enabled_succeeds", Caller: allowlisttest.TestEnabledAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(rewardmanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackSetRewardAddress(rewardAddress) + input, err := rewardmanager.PackSetRewardAddress(rewardAddress) require.NoError(t, err) return input }, - SuppliedGas: SetRewardAddressGasCost + RewardAddressChangedEventGasCost, + SuppliedGas: rewardmanager.SetRewardAddressGasCost + rewardmanager.RewardAddressChangedEventGasCost, ReadOnly: false, ExpectedRes: []byte{}, AfterHook: func(t testing.TB, state *extstate.StateDB) { - address, isFeeRecipients := GetStoredRewardAddress(state) + address, isFeeRecipients := rewardmanager.GetStoredRewardAddress(state) require.Equal(t, rewardAddress, address) require.False(t, isFeeRecipients) @@ -138,18 +139,18 @@ var ( { Name: "set_allow_fee_recipients_from_manager_succeeds", Caller: allowlisttest.TestManagerAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(rewardmanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackAllowFeeRecipients() + input, err := rewardmanager.PackAllowFeeRecipients() require.NoError(t, err) return input }, - SuppliedGas: AllowFeeRecipientsGasCost + FeeRecipientsAllowedEventGasCost, + SuppliedGas: rewardmanager.AllowFeeRecipientsGasCost + rewardmanager.FeeRecipientsAllowedEventGasCost, ReadOnly: false, ExpectedRes: []byte{}, AfterHook: func(t testing.TB, state *extstate.StateDB) { - _, isFeeRecipients := GetStoredRewardAddress(state) + _, isFeeRecipients := rewardmanager.GetStoredRewardAddress(state) require.True(t, isFeeRecipients) logs := state.Logs() @@ -159,18 +160,18 @@ var ( { Name: "set_reward_address_from_manager_succeeds", Caller: allowlisttest.TestManagerAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(rewardmanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackSetRewardAddress(rewardAddress) + input, err := rewardmanager.PackSetRewardAddress(rewardAddress) require.NoError(t, err) return input }, - SuppliedGas: SetRewardAddressGasCost + RewardAddressChangedEventGasCost, + SuppliedGas: rewardmanager.SetRewardAddressGasCost + rewardmanager.RewardAddressChangedEventGasCost, ReadOnly: false, ExpectedRes: []byte{}, AfterHook: func(t testing.TB, state *extstate.StateDB) { - address, isFeeRecipients := GetStoredRewardAddress(state) + address, isFeeRecipients := rewardmanager.GetStoredRewardAddress(state) require.Equal(t, rewardAddress, address) require.False(t, isFeeRecipients) @@ -181,9 +182,9 @@ var ( { Name: "change_reward_address_should_not_emit_events_pre_Durango", Caller: allowlisttest.TestManagerAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(rewardmanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackSetRewardAddress(rewardAddress) + input, err := rewardmanager.PackSetRewardAddress(rewardAddress) require.NoError(t, err) return input @@ -195,7 +196,7 @@ var ( mockChainConfig.EXPECT().IsDurango(gomock.Any()).AnyTimes().Return(false) return mockChainConfig }, - SuppliedGas: SetRewardAddressGasCost, + SuppliedGas: rewardmanager.SetRewardAddressGasCost, ReadOnly: false, ExpectedRes: []byte{}, AfterHook: func(t testing.TB, stateDB *extstate.StateDB) { @@ -207,18 +208,18 @@ var ( { Name: "disable_rewards_from_manager_succeeds", Caller: allowlisttest.TestManagerAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(rewardmanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackDisableRewards() + input, err := rewardmanager.PackDisableRewards() require.NoError(t, err) return input }, - SuppliedGas: DisableRewardsGasCost + RewardsDisabledEventGasCost, + SuppliedGas: rewardmanager.DisableRewardsGasCost + rewardmanager.RewardsDisabledEventGasCost, ReadOnly: false, ExpectedRes: []byte{}, AfterHook: func(t testing.TB, state *extstate.StateDB) { - address, isFeeRecipients := GetStoredRewardAddress(state) + address, isFeeRecipients := rewardmanager.GetStoredRewardAddress(state) require.False(t, isFeeRecipients) require.Equal(t, constants.BlackholeAddr, address) @@ -229,18 +230,18 @@ var ( { Name: "disable_rewards_from_enabled_succeeds", Caller: allowlisttest.TestEnabledAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(rewardmanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackDisableRewards() + input, err := rewardmanager.PackDisableRewards() require.NoError(t, err) return input }, - SuppliedGas: DisableRewardsGasCost + RewardsDisabledEventGasCost, + SuppliedGas: rewardmanager.DisableRewardsGasCost + rewardmanager.RewardsDisabledEventGasCost, ReadOnly: false, ExpectedRes: []byte{}, AfterHook: func(t testing.TB, state *extstate.StateDB) { - address, isFeeRecipients := GetStoredRewardAddress(state) + address, isFeeRecipients := rewardmanager.GetStoredRewardAddress(state) require.False(t, isFeeRecipients) require.Equal(t, constants.BlackholeAddr, address) @@ -251,9 +252,9 @@ var ( { Name: "disable_rewards_should_not_emit_event_pre_Durango", Caller: allowlisttest.TestManagerAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(rewardmanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackDisableRewards() + input, err := rewardmanager.PackDisableRewards() require.NoError(t, err) return input @@ -265,7 +266,7 @@ var ( mockChainConfig.EXPECT().IsDurango(gomock.Any()).AnyTimes().Return(false) return mockChainConfig }, - SuppliedGas: SetRewardAddressGasCost, + SuppliedGas: rewardmanager.SetRewardAddressGasCost, ReadOnly: false, ExpectedRes: []byte{}, AfterHook: func(t testing.TB, stateDB *extstate.StateDB) { @@ -278,19 +279,19 @@ var ( Name: "get_current_reward_address_from_no_role_succeeds", Caller: allowlisttest.TestNoRoleAddr, BeforeHook: func(t testing.TB, state *extstate.StateDB) { - allowlisttest.SetDefaultRoles(Module.Address)(t, state) - StoreRewardAddress(state, rewardAddress) + allowlisttest.SetDefaultRoles(rewardmanager.Module.Address)(t, state) + rewardmanager.StoreRewardAddress(state, rewardAddress) }, InputFn: func(t testing.TB) []byte { - input, err := PackCurrentRewardAddress() + input, err := rewardmanager.PackCurrentRewardAddress() require.NoError(t, err) return input }, - SuppliedGas: CurrentRewardAddressGasCost, + SuppliedGas: rewardmanager.CurrentRewardAddressGasCost, ReadOnly: false, ExpectedRes: func() []byte { - res, err := PackCurrentRewardAddressOutput(rewardAddress) + res, err := rewardmanager.PackCurrentRewardAddressOutput(rewardAddress) if err != nil { panic(err) } @@ -301,18 +302,18 @@ var ( Name: "get_are_fee_recipients_allowed_from_no_role_succeeds", Caller: allowlisttest.TestNoRoleAddr, BeforeHook: func(t testing.TB, state *extstate.StateDB) { - allowlisttest.SetDefaultRoles(Module.Address)(t, state) - EnableAllowFeeRecipients(state) + allowlisttest.SetDefaultRoles(rewardmanager.Module.Address)(t, state) + rewardmanager.EnableAllowFeeRecipients(state) }, InputFn: func(t testing.TB) []byte { - input, err := PackAreFeeRecipientsAllowed() + input, err := rewardmanager.PackAreFeeRecipientsAllowed() require.NoError(t, err) return input }, - SuppliedGas: AreFeeRecipientsAllowedGasCost, + SuppliedGas: rewardmanager.AreFeeRecipientsAllowedGasCost, ReadOnly: false, ExpectedRes: func() []byte { - res, err := PackAreFeeRecipientsAllowedOutput(true) + res, err := rewardmanager.PackAreFeeRecipientsAllowedOutput(true) if err != nil { panic(err) } @@ -322,21 +323,21 @@ var ( { Name: "get_initial_config_with_address", Caller: allowlisttest.TestNoRoleAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(rewardmanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackCurrentRewardAddress() + input, err := rewardmanager.PackCurrentRewardAddress() require.NoError(t, err) return input }, - SuppliedGas: CurrentRewardAddressGasCost, - Config: &Config{ - InitialRewardConfig: &InitialRewardConfig{ + SuppliedGas: rewardmanager.CurrentRewardAddressGasCost, + Config: &rewardmanager.Config{ + InitialRewardConfig: &rewardmanager.InitialRewardConfig{ RewardAddress: rewardAddress, }, }, ReadOnly: false, ExpectedRes: func() []byte { - res, err := PackCurrentRewardAddressOutput(rewardAddress) + res, err := rewardmanager.PackCurrentRewardAddressOutput(rewardAddress) if err != nil { panic(err) } @@ -346,21 +347,21 @@ var ( { Name: "get_initial_config_with_allow_fee_recipients_enabled", Caller: allowlisttest.TestNoRoleAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(rewardmanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackAreFeeRecipientsAllowed() + input, err := rewardmanager.PackAreFeeRecipientsAllowed() require.NoError(t, err) return input }, - SuppliedGas: AreFeeRecipientsAllowedGasCost, - Config: &Config{ - InitialRewardConfig: &InitialRewardConfig{ + SuppliedGas: rewardmanager.AreFeeRecipientsAllowedGasCost, + Config: &rewardmanager.Config{ + InitialRewardConfig: &rewardmanager.InitialRewardConfig{ AllowFeeRecipients: true, }, }, ReadOnly: false, ExpectedRes: func() []byte { - res, err := PackAreFeeRecipientsAllowedOutput(true) + res, err := rewardmanager.PackAreFeeRecipientsAllowedOutput(true) if err != nil { panic(err) } @@ -370,84 +371,84 @@ var ( { Name: "readOnly_allow_fee_recipients_with_allowed_role_fails", Caller: allowlisttest.TestEnabledAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(rewardmanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackAllowFeeRecipients() + input, err := rewardmanager.PackAllowFeeRecipients() require.NoError(t, err) return input }, - SuppliedGas: AllowFeeRecipientsGasCost, + SuppliedGas: rewardmanager.AllowFeeRecipientsGasCost, ReadOnly: true, ExpectedErr: vm.ErrWriteProtection.Error(), }, { Name: "readOnly_set_reward_address_with_allowed_role_fails", Caller: allowlisttest.TestEnabledAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(rewardmanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackSetRewardAddress(rewardAddress) + input, err := rewardmanager.PackSetRewardAddress(rewardAddress) require.NoError(t, err) return input }, - SuppliedGas: SetRewardAddressGasCost, + SuppliedGas: rewardmanager.SetRewardAddressGasCost, ReadOnly: true, ExpectedErr: vm.ErrWriteProtection.Error(), }, { Name: "insufficient_gas_set_reward_address_from_allowed_role", Caller: allowlisttest.TestEnabledAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(rewardmanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackSetRewardAddress(rewardAddress) + input, err := rewardmanager.PackSetRewardAddress(rewardAddress) require.NoError(t, err) return input }, - SuppliedGas: SetRewardAddressGasCost + RewardAddressChangedEventGasCost - 1, + SuppliedGas: rewardmanager.SetRewardAddressGasCost + rewardmanager.RewardAddressChangedEventGasCost - 1, ReadOnly: false, ExpectedErr: vm.ErrOutOfGas.Error(), }, { Name: "insufficient_gas_allow_fee_recipients_from_allowed_role", Caller: allowlisttest.TestEnabledAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(rewardmanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackAllowFeeRecipients() + input, err := rewardmanager.PackAllowFeeRecipients() require.NoError(t, err) return input }, - SuppliedGas: AllowFeeRecipientsGasCost + FeeRecipientsAllowedEventGasCost - 1, + SuppliedGas: rewardmanager.AllowFeeRecipientsGasCost + rewardmanager.FeeRecipientsAllowedEventGasCost - 1, ReadOnly: false, ExpectedErr: vm.ErrOutOfGas.Error(), }, { Name: "insufficient_gas_read_current_reward_address_from_allowed_role", Caller: allowlisttest.TestEnabledAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(rewardmanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackCurrentRewardAddress() + input, err := rewardmanager.PackCurrentRewardAddress() require.NoError(t, err) return input }, - SuppliedGas: CurrentRewardAddressGasCost - 1, + SuppliedGas: rewardmanager.CurrentRewardAddressGasCost - 1, ReadOnly: false, ExpectedErr: vm.ErrOutOfGas.Error(), }, { Name: "insufficient_gas_are_fee_recipients_allowed_from_allowed_role", Caller: allowlisttest.TestEnabledAddr, - BeforeHook: allowlisttest.SetDefaultRoles(Module.Address), + BeforeHook: allowlisttest.SetDefaultRoles(rewardmanager.Module.Address), InputFn: func(t testing.TB) []byte { - input, err := PackAreFeeRecipientsAllowed() + input, err := rewardmanager.PackAreFeeRecipientsAllowed() require.NoError(t, err) return input }, - SuppliedGas: AreFeeRecipientsAllowedGasCost - 1, + SuppliedGas: rewardmanager.AreFeeRecipientsAllowedGasCost - 1, ReadOnly: false, ExpectedErr: vm.ErrOutOfGas.Error(), }, @@ -455,7 +456,7 @@ var ( ) func TestRewardManagerRun(t *testing.T) { - allowlisttest.RunPrecompileWithAllowListTests(t, Module, tests) + allowlisttest.RunPrecompileWithAllowListTests(t, rewardmanager.Module, tests) } func assertRewardAddressChanged( @@ -470,7 +471,7 @@ func assertRewardAddressChanged( require.Equal( t, []common.Hash{ - RewardManagerABI.Events["RewardAddressChanged"].ID, + rewardmanager.RewardManagerABI.Events["RewardAddressChanged"].ID, common.BytesToHash(caller[:]), common.BytesToHash(oldAddress[:]), common.BytesToHash(newAddress[:]), @@ -490,7 +491,7 @@ func assertRewardsDisabled( require.Equal( t, []common.Hash{ - RewardManagerABI.Events["RewardsDisabled"].ID, + rewardmanager.RewardManagerABI.Events["RewardsDisabled"].ID, common.BytesToHash(caller[:]), }, log.Topics, @@ -508,7 +509,7 @@ func assertFeeRecipientsAllowed( require.Equal( t, []common.Hash{ - RewardManagerABI.Events["FeeRecipientsAllowed"].ID, + rewardmanager.RewardManagerABI.Events["FeeRecipientsAllowed"].ID, common.BytesToHash(caller[:]), }, log.Topics, diff --git a/precompile/contracts/testutils/simulated_helpers.go b/precompile/contracts/testutils/simulated_helpers.go new file mode 100644 index 0000000000..739a4b4134 --- /dev/null +++ b/precompile/contracts/testutils/simulated_helpers.go @@ -0,0 +1,42 @@ +// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +package testutils + +import ( + "crypto/ecdsa" + "math/big" + "testing" + + "github.com/ava-labs/libevm/core/types" + "github.com/stretchr/testify/require" + + "github.com/ava-labs/subnet-evm/accounts/abi/bind" + + sim "github.com/ava-labs/subnet-evm/ethclient/simulated" +) + +// NewAuth creates a new transactor with the given private key and chain ID. +func NewAuth(t *testing.T, key *ecdsa.PrivateKey, chainID *big.Int) *bind.TransactOpts { + t.Helper() + auth, err := bind.NewKeyedTransactorWithChainID(key, chainID) + require.NoError(t, err) + return auth +} + +// WaitReceipt commits the simulated backend and waits for the transaction receipt. +func WaitReceipt(t *testing.T, b *sim.Backend, tx *types.Transaction) *types.Receipt { + t.Helper() + b.Commit(true) + receipt, err := b.Client().TransactionReceipt(t.Context(), tx.Hash()) + require.NoError(t, err, "failed to get transaction receipt") + return receipt +} + +// WaitReceiptSuccessful commits the backend, waits for the receipt, and asserts success. +func WaitReceiptSuccessful(t *testing.T, b *sim.Backend, tx *types.Transaction) *types.Receipt { + t.Helper() + receipt := WaitReceipt(t, b, tx) + require.Equal(t, types.ReceiptStatusSuccessful, receipt.Status, "transaction should succeed") + return receipt +} diff --git a/precompile/contracts/txallowlist/config_test.go b/precompile/contracts/txallowlist/config_test.go index 31ecf4aaea..61b2a6b2ef 100644 --- a/precompile/contracts/txallowlist/config_test.go +++ b/precompile/contracts/txallowlist/config_test.go @@ -1,7 +1,7 @@ // Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package txallowlist +package txallowlist_test import ( "testing" @@ -10,13 +10,14 @@ import ( "go.uber.org/mock/gomock" "github.com/ava-labs/subnet-evm/precompile/allowlist/allowlisttest" + "github.com/ava-labs/subnet-evm/precompile/contracts/txallowlist" "github.com/ava-labs/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/subnet-evm/precompile/precompiletest" "github.com/ava-labs/subnet-evm/utils" ) func TestVerify(t *testing.T) { - allowlisttest.VerifyPrecompileWithAllowListTests(t, Module, nil) + allowlisttest.VerifyPrecompileWithAllowListTests(t, txallowlist.Module, nil) } func TestEqual(t *testing.T) { @@ -25,25 +26,25 @@ func TestEqual(t *testing.T) { managers := []common.Address{allowlisttest.TestManagerAddr} tests := map[string]precompiletest.ConfigEqualTest{ "non-nil config and nil other": { - Config: NewConfig(utils.NewUint64(3), admins, enableds, managers), + Config: txallowlist.NewConfig(utils.NewUint64(3), admins, enableds, managers), Other: nil, Expected: false, }, "different type": { - Config: NewConfig(nil, nil, nil, nil), + Config: txallowlist.NewConfig(nil, nil, nil, nil), Other: precompileconfig.NewMockConfig(gomock.NewController(t)), Expected: false, }, "different timestamp": { - Config: NewConfig(utils.NewUint64(3), admins, enableds, managers), - Other: NewConfig(utils.NewUint64(4), admins, enableds, managers), + Config: txallowlist.NewConfig(utils.NewUint64(3), admins, enableds, managers), + Other: txallowlist.NewConfig(utils.NewUint64(4), admins, enableds, managers), Expected: false, }, "same config": { - Config: NewConfig(utils.NewUint64(3), admins, enableds, managers), - Other: NewConfig(utils.NewUint64(3), admins, enableds, managers), + Config: txallowlist.NewConfig(utils.NewUint64(3), admins, enableds, managers), + Other: txallowlist.NewConfig(utils.NewUint64(3), admins, enableds, managers), Expected: true, }, } - allowlisttest.EqualPrecompileWithAllowListTests(t, Module, tests) + allowlisttest.EqualPrecompileWithAllowListTests(t, txallowlist.Module, tests) } diff --git a/precompile/contracts/txallowlist/contract_test.go b/precompile/contracts/txallowlist/contract_test.go index bdbe3b7c1b..26aebc18d4 100644 --- a/precompile/contracts/txallowlist/contract_test.go +++ b/precompile/contracts/txallowlist/contract_test.go @@ -1,14 +1,15 @@ // Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package txallowlist +package txallowlist_test import ( "testing" "github.com/ava-labs/subnet-evm/precompile/allowlist/allowlisttest" + "github.com/ava-labs/subnet-evm/precompile/contracts/txallowlist" ) func TestTxAllowListRun(t *testing.T) { - allowlisttest.RunPrecompileWithAllowListTests(t, Module, nil) + allowlisttest.RunPrecompileWithAllowListTests(t, txallowlist.Module, nil) } diff --git a/scripts/shellcheck.sh b/scripts/shellcheck.sh index f57b853362..e2a0420c04 100755 --- a/scripts/shellcheck.sh +++ b/scripts/shellcheck.sh @@ -5,11 +5,13 @@ set -euo pipefail VERSION="v0.9.0" # Scripts that are sourced from upstream and not maintained in this repo will not be shellchecked. -# Also ignore the local avalanchego clone. +# Also ignore the local avalanchego clone, git submodules, and node_modules. IGNORED_FILES=" cmd/evm/transition-test.sh metrics/validate.sh avalanchego/* + contracts/lib/* + contracts/node_modules/* " function get_version { diff --git a/tests/precompile/solidity/suites.go b/tests/precompile/solidity/suites.go index 66d897ffde..63cdafedf3 100644 --- a/tests/precompile/solidity/suites.go +++ b/tests/precompile/solidity/suites.go @@ -36,13 +36,6 @@ func RegisterAsyncTests() { // Each ginkgo It node specifies the name of the genesis file (in ./tests/precompile/genesis/) // to use to launch the subnet and the name of the TS test file to run on the subnet (in ./contracts/tests/) - ginkgo.It("contract native minter", ginkgo.Label("Precompile"), ginkgo.Label("ContractNativeMinter"), func() { - ctx, cancel := context.WithTimeout(context.Background(), timeout) - defer cancel() - - blockchainID := subnetsSuite.GetBlockchainID("contract_native_minter") - runDefaultHardhatTests(ctx, blockchainID, "contract_native_minter") - }) ginkgo.It("tx allow list", ginkgo.Label("Precompile"), ginkgo.Label("TxAllowList"), func() { ctx, cancel := context.WithTimeout(context.Background(), timeout)