diff --git a/pkg/contracts/prototypes/erc20custodynew.sol/erc20custodynew.go b/pkg/contracts/prototypes/erc20custodynew.sol/erc20custodynew.go new file mode 100644 index 00000000..0e921cd7 --- /dev/null +++ b/pkg/contracts/prototypes/erc20custodynew.sol/erc20custodynew.go @@ -0,0 +1,585 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package erc20custodynew + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/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 +) + +// ERC20CustodyNewMetaData contains all meta data concerning the ERC20CustodyNew contract. +var ERC20CustodyNewMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_gateway\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Withdraw\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"WithdrawAndCall\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"gateway\",\"outputs\":[{\"internalType\":\"contractGateway\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"withdraw\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"withdrawAndCall\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x608060405234801561001057600080fd5b50604051610a66380380610a668339818101604052810190610032919061008d565b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610108565b600081519050610087816100f1565b92915050565b6000602082840312156100a3576100a26100ec565b5b60006100b184828501610078565b91505092915050565b60006100c5826100cc565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600080fd5b6100fa816100ba565b811461010557600080fd5b50565b61094f806101176000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063116191b61461004657806321fc65f214610064578063d9caed1214610080575b600080fd5b61004e61009c565b60405161005b91906106b6565b60405180910390f35b61007e600480360381019061007991906104e7565b6100c0565b005b61009a60048036038101906100959190610494565b610297565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b8473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff16856040518363ffffffff1660e01b815260040161011b92919061068d565b602060405180830381600087803b15801561013557600080fd5b505af1158015610149573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061016d919061056f565b5060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16635131ab5986868686866040518663ffffffff1660e01b81526004016101cf95949392919061063f565b600060405180830381600087803b1580156101e957600080fd5b505af11580156101fd573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190610226919061059c565b508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f85b5be9cf454e05e0bddf49315178102227c312078eefa3c00294fb4d912ae4e858585604051610288939291906106ec565b60405180910390a35050505050565b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb83836040518363ffffffff1660e01b81526004016102d292919061068d565b602060405180830381600087803b1580156102ec57600080fd5b505af1158015610300573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610324919061056f565b508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f9b1bfa7fa9ee420a16e124f794c35ac9f90472acc99140eb2f6447c714cad8eb8360405161038291906106d1565b60405180910390a3505050565b60006103a261039d84610743565b61071e565b9050828152602081018484840111156103be576103bd6108b4565b5b6103c9848285610812565b509392505050565b6000813590506103e0816108d4565b92915050565b6000815190506103f5816108eb565b92915050565b60008083601f840112610411576104106108aa565b5b8235905067ffffffffffffffff81111561042e5761042d6108a5565b5b60208301915083600182028301111561044a576104496108af565b5b9250929050565b600082601f830112610466576104656108aa565b5b815161047684826020860161038f565b91505092915050565b60008135905061048e81610902565b92915050565b6000806000606084860312156104ad576104ac6108be565b5b60006104bb868287016103d1565b93505060206104cc868287016103d1565b92505060406104dd8682870161047f565b9150509250925092565b600080600080600060808688031215610503576105026108be565b5b6000610511888289016103d1565b9550506020610522888289016103d1565b94505060406105338882890161047f565b935050606086013567ffffffffffffffff811115610554576105536108b9565b5b610560888289016103fb565b92509250509295509295909350565b600060208284031215610585576105846108be565b5b6000610593848285016103e6565b91505092915050565b6000602082840312156105b2576105b16108be565b5b600082015167ffffffffffffffff8111156105d0576105cf6108b9565b5b6105dc84828501610451565b91505092915050565b6105ee81610785565b82525050565b60006106008385610774565b935061060d838584610803565b610616836108c3565b840190509392505050565b61062a816107cd565b82525050565b610639816107c3565b82525050565b600060808201905061065460008301886105e5565b61066160208301876105e5565b61066e6040830186610630565b81810360608301526106818184866105f4565b90509695505050505050565b60006040820190506106a260008301856105e5565b6106af6020830184610630565b9392505050565b60006020820190506106cb6000830184610621565b92915050565b60006020820190506106e66000830184610630565b92915050565b60006040820190506107016000830186610630565b81810360208301526107148184866105f4565b9050949350505050565b6000610728610739565b90506107348282610845565b919050565b6000604051905090565b600067ffffffffffffffff82111561075e5761075d610876565b5b610767826108c3565b9050602081019050919050565b600082825260208201905092915050565b6000610790826107a3565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006107d8826107df565b9050919050565b60006107ea826107f1565b9050919050565b60006107fc826107a3565b9050919050565b82818337600083830152505050565b60005b83811015610830578082015181840152602081019050610815565b8381111561083f576000848401525b50505050565b61084e826108c3565b810181811067ffffffffffffffff8211171561086d5761086c610876565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b6108dd81610785565b81146108e857600080fd5b50565b6108f481610797565b81146108ff57600080fd5b50565b61090b816107c3565b811461091657600080fd5b5056fea26469706673582212204a3850d22f33c03cceb6ae5ac36c3c4c9cba7201ec5196e96268ce7606e4ef5564736f6c63430008070033", +} + +// ERC20CustodyNewABI is the input ABI used to generate the binding from. +// Deprecated: Use ERC20CustodyNewMetaData.ABI instead. +var ERC20CustodyNewABI = ERC20CustodyNewMetaData.ABI + +// ERC20CustodyNewBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use ERC20CustodyNewMetaData.Bin instead. +var ERC20CustodyNewBin = ERC20CustodyNewMetaData.Bin + +// DeployERC20CustodyNew deploys a new Ethereum contract, binding an instance of ERC20CustodyNew to it. +func DeployERC20CustodyNew(auth *bind.TransactOpts, backend bind.ContractBackend, _gateway common.Address) (common.Address, *types.Transaction, *ERC20CustodyNew, error) { + parsed, err := ERC20CustodyNewMetaData.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(ERC20CustodyNewBin), backend, _gateway) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &ERC20CustodyNew{ERC20CustodyNewCaller: ERC20CustodyNewCaller{contract: contract}, ERC20CustodyNewTransactor: ERC20CustodyNewTransactor{contract: contract}, ERC20CustodyNewFilterer: ERC20CustodyNewFilterer{contract: contract}}, nil +} + +// ERC20CustodyNew is an auto generated Go binding around an Ethereum contract. +type ERC20CustodyNew struct { + ERC20CustodyNewCaller // Read-only binding to the contract + ERC20CustodyNewTransactor // Write-only binding to the contract + ERC20CustodyNewFilterer // Log filterer for contract events +} + +// ERC20CustodyNewCaller is an auto generated read-only Go binding around an Ethereum contract. +type ERC20CustodyNewCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ERC20CustodyNewTransactor is an auto generated write-only Go binding around an Ethereum contract. +type ERC20CustodyNewTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ERC20CustodyNewFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type ERC20CustodyNewFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ERC20CustodyNewSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type ERC20CustodyNewSession struct { + Contract *ERC20CustodyNew // 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 +} + +// ERC20CustodyNewCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type ERC20CustodyNewCallerSession struct { + Contract *ERC20CustodyNewCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// ERC20CustodyNewTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type ERC20CustodyNewTransactorSession struct { + Contract *ERC20CustodyNewTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ERC20CustodyNewRaw is an auto generated low-level Go binding around an Ethereum contract. +type ERC20CustodyNewRaw struct { + Contract *ERC20CustodyNew // Generic contract binding to access the raw methods on +} + +// ERC20CustodyNewCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type ERC20CustodyNewCallerRaw struct { + Contract *ERC20CustodyNewCaller // Generic read-only contract binding to access the raw methods on +} + +// ERC20CustodyNewTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type ERC20CustodyNewTransactorRaw struct { + Contract *ERC20CustodyNewTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewERC20CustodyNew creates a new instance of ERC20CustodyNew, bound to a specific deployed contract. +func NewERC20CustodyNew(address common.Address, backend bind.ContractBackend) (*ERC20CustodyNew, error) { + contract, err := bindERC20CustodyNew(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &ERC20CustodyNew{ERC20CustodyNewCaller: ERC20CustodyNewCaller{contract: contract}, ERC20CustodyNewTransactor: ERC20CustodyNewTransactor{contract: contract}, ERC20CustodyNewFilterer: ERC20CustodyNewFilterer{contract: contract}}, nil +} + +// NewERC20CustodyNewCaller creates a new read-only instance of ERC20CustodyNew, bound to a specific deployed contract. +func NewERC20CustodyNewCaller(address common.Address, caller bind.ContractCaller) (*ERC20CustodyNewCaller, error) { + contract, err := bindERC20CustodyNew(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &ERC20CustodyNewCaller{contract: contract}, nil +} + +// NewERC20CustodyNewTransactor creates a new write-only instance of ERC20CustodyNew, bound to a specific deployed contract. +func NewERC20CustodyNewTransactor(address common.Address, transactor bind.ContractTransactor) (*ERC20CustodyNewTransactor, error) { + contract, err := bindERC20CustodyNew(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &ERC20CustodyNewTransactor{contract: contract}, nil +} + +// NewERC20CustodyNewFilterer creates a new log filterer instance of ERC20CustodyNew, bound to a specific deployed contract. +func NewERC20CustodyNewFilterer(address common.Address, filterer bind.ContractFilterer) (*ERC20CustodyNewFilterer, error) { + contract, err := bindERC20CustodyNew(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &ERC20CustodyNewFilterer{contract: contract}, nil +} + +// bindERC20CustodyNew binds a generic wrapper to an already deployed contract. +func bindERC20CustodyNew(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := ERC20CustodyNewMetaData.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 (_ERC20CustodyNew *ERC20CustodyNewRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _ERC20CustodyNew.Contract.ERC20CustodyNewCaller.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 (_ERC20CustodyNew *ERC20CustodyNewRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ERC20CustodyNew.Contract.ERC20CustodyNewTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_ERC20CustodyNew *ERC20CustodyNewRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _ERC20CustodyNew.Contract.ERC20CustodyNewTransactor.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 (_ERC20CustodyNew *ERC20CustodyNewCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _ERC20CustodyNew.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 (_ERC20CustodyNew *ERC20CustodyNewTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ERC20CustodyNew.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_ERC20CustodyNew *ERC20CustodyNewTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _ERC20CustodyNew.Contract.contract.Transact(opts, method, params...) +} + +// Gateway is a free data retrieval call binding the contract method 0x116191b6. +// +// Solidity: function gateway() view returns(address) +func (_ERC20CustodyNew *ERC20CustodyNewCaller) Gateway(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _ERC20CustodyNew.contract.Call(opts, &out, "gateway") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Gateway is a free data retrieval call binding the contract method 0x116191b6. +// +// Solidity: function gateway() view returns(address) +func (_ERC20CustodyNew *ERC20CustodyNewSession) Gateway() (common.Address, error) { + return _ERC20CustodyNew.Contract.Gateway(&_ERC20CustodyNew.CallOpts) +} + +// Gateway is a free data retrieval call binding the contract method 0x116191b6. +// +// Solidity: function gateway() view returns(address) +func (_ERC20CustodyNew *ERC20CustodyNewCallerSession) Gateway() (common.Address, error) { + return _ERC20CustodyNew.Contract.Gateway(&_ERC20CustodyNew.CallOpts) +} + +// Withdraw is a paid mutator transaction binding the contract method 0xd9caed12. +// +// Solidity: function withdraw(address token, address to, uint256 amount) returns() +func (_ERC20CustodyNew *ERC20CustodyNewTransactor) Withdraw(opts *bind.TransactOpts, token common.Address, to common.Address, amount *big.Int) (*types.Transaction, error) { + return _ERC20CustodyNew.contract.Transact(opts, "withdraw", token, to, amount) +} + +// Withdraw is a paid mutator transaction binding the contract method 0xd9caed12. +// +// Solidity: function withdraw(address token, address to, uint256 amount) returns() +func (_ERC20CustodyNew *ERC20CustodyNewSession) Withdraw(token common.Address, to common.Address, amount *big.Int) (*types.Transaction, error) { + return _ERC20CustodyNew.Contract.Withdraw(&_ERC20CustodyNew.TransactOpts, token, to, amount) +} + +// Withdraw is a paid mutator transaction binding the contract method 0xd9caed12. +// +// Solidity: function withdraw(address token, address to, uint256 amount) returns() +func (_ERC20CustodyNew *ERC20CustodyNewTransactorSession) Withdraw(token common.Address, to common.Address, amount *big.Int) (*types.Transaction, error) { + return _ERC20CustodyNew.Contract.Withdraw(&_ERC20CustodyNew.TransactOpts, token, to, amount) +} + +// WithdrawAndCall is a paid mutator transaction binding the contract method 0x21fc65f2. +// +// Solidity: function withdrawAndCall(address token, address to, uint256 amount, bytes data) returns() +func (_ERC20CustodyNew *ERC20CustodyNewTransactor) WithdrawAndCall(opts *bind.TransactOpts, token common.Address, to common.Address, amount *big.Int, data []byte) (*types.Transaction, error) { + return _ERC20CustodyNew.contract.Transact(opts, "withdrawAndCall", token, to, amount, data) +} + +// WithdrawAndCall is a paid mutator transaction binding the contract method 0x21fc65f2. +// +// Solidity: function withdrawAndCall(address token, address to, uint256 amount, bytes data) returns() +func (_ERC20CustodyNew *ERC20CustodyNewSession) WithdrawAndCall(token common.Address, to common.Address, amount *big.Int, data []byte) (*types.Transaction, error) { + return _ERC20CustodyNew.Contract.WithdrawAndCall(&_ERC20CustodyNew.TransactOpts, token, to, amount, data) +} + +// WithdrawAndCall is a paid mutator transaction binding the contract method 0x21fc65f2. +// +// Solidity: function withdrawAndCall(address token, address to, uint256 amount, bytes data) returns() +func (_ERC20CustodyNew *ERC20CustodyNewTransactorSession) WithdrawAndCall(token common.Address, to common.Address, amount *big.Int, data []byte) (*types.Transaction, error) { + return _ERC20CustodyNew.Contract.WithdrawAndCall(&_ERC20CustodyNew.TransactOpts, token, to, amount, data) +} + +// ERC20CustodyNewWithdrawIterator is returned from FilterWithdraw and is used to iterate over the raw logs and unpacked data for Withdraw events raised by the ERC20CustodyNew contract. +type ERC20CustodyNewWithdrawIterator struct { + Event *ERC20CustodyNewWithdraw // 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 *ERC20CustodyNewWithdrawIterator) 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(ERC20CustodyNewWithdraw) + 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(ERC20CustodyNewWithdraw) + 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 *ERC20CustodyNewWithdrawIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ERC20CustodyNewWithdrawIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ERC20CustodyNewWithdraw represents a Withdraw event raised by the ERC20CustodyNew contract. +type ERC20CustodyNewWithdraw struct { + Token common.Address + To common.Address + Amount *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterWithdraw is a free log retrieval operation binding the contract event 0x9b1bfa7fa9ee420a16e124f794c35ac9f90472acc99140eb2f6447c714cad8eb. +// +// Solidity: event Withdraw(address indexed token, address indexed to, uint256 amount) +func (_ERC20CustodyNew *ERC20CustodyNewFilterer) FilterWithdraw(opts *bind.FilterOpts, token []common.Address, to []common.Address) (*ERC20CustodyNewWithdrawIterator, error) { + + var tokenRule []interface{} + for _, tokenItem := range token { + tokenRule = append(tokenRule, tokenItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _ERC20CustodyNew.contract.FilterLogs(opts, "Withdraw", tokenRule, toRule) + if err != nil { + return nil, err + } + return &ERC20CustodyNewWithdrawIterator{contract: _ERC20CustodyNew.contract, event: "Withdraw", logs: logs, sub: sub}, nil +} + +// WatchWithdraw is a free log subscription operation binding the contract event 0x9b1bfa7fa9ee420a16e124f794c35ac9f90472acc99140eb2f6447c714cad8eb. +// +// Solidity: event Withdraw(address indexed token, address indexed to, uint256 amount) +func (_ERC20CustodyNew *ERC20CustodyNewFilterer) WatchWithdraw(opts *bind.WatchOpts, sink chan<- *ERC20CustodyNewWithdraw, token []common.Address, to []common.Address) (event.Subscription, error) { + + var tokenRule []interface{} + for _, tokenItem := range token { + tokenRule = append(tokenRule, tokenItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _ERC20CustodyNew.contract.WatchLogs(opts, "Withdraw", tokenRule, 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(ERC20CustodyNewWithdraw) + if err := _ERC20CustodyNew.contract.UnpackLog(event, "Withdraw", 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 +} + +// ParseWithdraw is a log parse operation binding the contract event 0x9b1bfa7fa9ee420a16e124f794c35ac9f90472acc99140eb2f6447c714cad8eb. +// +// Solidity: event Withdraw(address indexed token, address indexed to, uint256 amount) +func (_ERC20CustodyNew *ERC20CustodyNewFilterer) ParseWithdraw(log types.Log) (*ERC20CustodyNewWithdraw, error) { + event := new(ERC20CustodyNewWithdraw) + if err := _ERC20CustodyNew.contract.UnpackLog(event, "Withdraw", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ERC20CustodyNewWithdrawAndCallIterator is returned from FilterWithdrawAndCall and is used to iterate over the raw logs and unpacked data for WithdrawAndCall events raised by the ERC20CustodyNew contract. +type ERC20CustodyNewWithdrawAndCallIterator struct { + Event *ERC20CustodyNewWithdrawAndCall // 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 *ERC20CustodyNewWithdrawAndCallIterator) 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(ERC20CustodyNewWithdrawAndCall) + 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(ERC20CustodyNewWithdrawAndCall) + 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 *ERC20CustodyNewWithdrawAndCallIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ERC20CustodyNewWithdrawAndCallIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ERC20CustodyNewWithdrawAndCall represents a WithdrawAndCall event raised by the ERC20CustodyNew contract. +type ERC20CustodyNewWithdrawAndCall struct { + Token common.Address + To common.Address + Amount *big.Int + Data []byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterWithdrawAndCall is a free log retrieval operation binding the contract event 0x85b5be9cf454e05e0bddf49315178102227c312078eefa3c00294fb4d912ae4e. +// +// Solidity: event WithdrawAndCall(address indexed token, address indexed to, uint256 amount, bytes data) +func (_ERC20CustodyNew *ERC20CustodyNewFilterer) FilterWithdrawAndCall(opts *bind.FilterOpts, token []common.Address, to []common.Address) (*ERC20CustodyNewWithdrawAndCallIterator, error) { + + var tokenRule []interface{} + for _, tokenItem := range token { + tokenRule = append(tokenRule, tokenItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _ERC20CustodyNew.contract.FilterLogs(opts, "WithdrawAndCall", tokenRule, toRule) + if err != nil { + return nil, err + } + return &ERC20CustodyNewWithdrawAndCallIterator{contract: _ERC20CustodyNew.contract, event: "WithdrawAndCall", logs: logs, sub: sub}, nil +} + +// WatchWithdrawAndCall is a free log subscription operation binding the contract event 0x85b5be9cf454e05e0bddf49315178102227c312078eefa3c00294fb4d912ae4e. +// +// Solidity: event WithdrawAndCall(address indexed token, address indexed to, uint256 amount, bytes data) +func (_ERC20CustodyNew *ERC20CustodyNewFilterer) WatchWithdrawAndCall(opts *bind.WatchOpts, sink chan<- *ERC20CustodyNewWithdrawAndCall, token []common.Address, to []common.Address) (event.Subscription, error) { + + var tokenRule []interface{} + for _, tokenItem := range token { + tokenRule = append(tokenRule, tokenItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _ERC20CustodyNew.contract.WatchLogs(opts, "WithdrawAndCall", tokenRule, 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(ERC20CustodyNewWithdrawAndCall) + if err := _ERC20CustodyNew.contract.UnpackLog(event, "WithdrawAndCall", 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 +} + +// ParseWithdrawAndCall is a log parse operation binding the contract event 0x85b5be9cf454e05e0bddf49315178102227c312078eefa3c00294fb4d912ae4e. +// +// Solidity: event WithdrawAndCall(address indexed token, address indexed to, uint256 amount, bytes data) +func (_ERC20CustodyNew *ERC20CustodyNewFilterer) ParseWithdrawAndCall(log types.Log) (*ERC20CustodyNewWithdrawAndCall, error) { + event := new(ERC20CustodyNewWithdrawAndCall) + if err := _ERC20CustodyNew.contract.UnpackLog(event, "WithdrawAndCall", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/pkg/contracts/prototypes/gateway.sol/gateway.go b/pkg/contracts/prototypes/gateway.sol/gateway.go index 5d4d40ff..8615305f 100644 --- a/pkg/contracts/prototypes/gateway.sol/gateway.go +++ b/pkg/contracts/prototypes/gateway.sol/gateway.go @@ -31,8 +31,8 @@ var ( // GatewayMetaData contains all meta data concerning the Gateway contract. var GatewayMetaData = &bind.MetaData{ - ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destination\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"Forwarded\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"destination\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"forwardCall\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"}]", - Bin: "0x608060405234801561001057600080fd5b506104d0806100206000396000f3fe60806040526004361061001e5760003560e01c806322bee49414610023575b600080fd5b61003d600480360381019061003891906101d0565b610053565b60405161004a9190610306565b60405180910390f35b60606000808573ffffffffffffffffffffffffffffffffffffffff163486866040516100809291906102ed565b60006040518083038185875af1925050503d80600081146100bd576040519150601f19603f3d011682016040523d82523d6000602084013e6100c2565b606091505b509150915081610107576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100fe90610328565b60405180910390fd5b8573ffffffffffffffffffffffffffffffffffffffff167fc1de93dfa06362c6a616cde73ec17d116c0d588dd1df70f27f91b500de207c4134878760405161015193929190610348565b60405180910390a280925050509392505050565b60008135905061017481610483565b92915050565b60008083601f8401126101905761018f610435565b5b8235905067ffffffffffffffff8111156101ad576101ac610430565b5b6020830191508360018202830111156101c9576101c861043a565b5b9250929050565b6000806000604084860312156101e9576101e8610444565b5b60006101f786828701610165565b935050602084013567ffffffffffffffff8111156102185761021761043f565b5b6102248682870161017a565b92509250509250925092565b600061023c8385610385565b93506102498385846103ee565b61025283610449565b840190509392505050565b60006102698385610396565b93506102768385846103ee565b82840190509392505050565b600061028d8261037a565b6102978185610385565b93506102a78185602086016103fd565b6102b081610449565b840191505092915050565b60006102c8600b836103a1565b91506102d38261045a565b602082019050919050565b6102e7816103e4565b82525050565b60006102fa82848661025d565b91508190509392505050565b600060208201905081810360008301526103208184610282565b905092915050565b60006020820190508181036000830152610341816102bb565b9050919050565b600060408201905061035d60008301866102de565b8181036020830152610370818486610230565b9050949350505050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b60006103bd826103c4565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b8381101561041b578082015181840152602081019050610400565b8381111561042a576000848401525b50505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f43616c6c206661696c6564000000000000000000000000000000000000000000600082015250565b61048c816103b2565b811461049757600080fd5b5056fea2646970667358221220c44eb350867255a4dcf321a851ce03d409f436ff506f33df5244731cd237fa9064736f6c63430008070033", + ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destination\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"Executed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"ExecutedWithERC20\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"custody\",\"outputs\":[{\"internalType\":\"contractERC20CustodyNew\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"destination\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"execute\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"executeWithERC20\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_custody\",\"type\":\"address\"}],\"name\":\"setCustody\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x608060405234801561001057600080fd5b50610b74806100206000396000f3fe60806040526004361061003f5760003560e01c80631cff79cd146100445780635131ab5914610074578063ae7a3a6f146100b1578063dda79b75146100da575b600080fd5b61005e600480360381019061005991906106e3565b610105565b60405161006b919061090d565b60405180910390f35b34801561008057600080fd5b5061009b6004803603810190610096919061065b565b610173565b6040516100a8919061090d565b60405180910390f35b3480156100bd57600080fd5b506100d860048036038101906100d3919061062e565b61045d565b005b3480156100e657600080fd5b506100ef6104a0565b6040516100fc919061092f565b60405180910390f35b606060006101148585856104c4565b90508473ffffffffffffffffffffffffffffffffffffffff167fcaf938de11c367272220bfd1d2baa99ca46665e7bc4d85f00adb51b90fe1fa9f3486866040516101609392919061096a565b60405180910390a2809150509392505050565b60608573ffffffffffffffffffffffffffffffffffffffff1663095ea7b386866040518363ffffffff1660e01b81526004016101b09291906108e4565b602060405180830381600087803b1580156101ca57600080fd5b505af11580156101de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102029190610743565b5060006102108685856104c4565b90508673ffffffffffffffffffffffffffffffffffffffff1663095ea7b38760006040518363ffffffff1660e01b815260040161024e9291906108bb565b602060405180830381600087803b15801561026857600080fd5b505af115801561027c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102a09190610743565b5060008773ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016102dc91906108a0565b60206040518083038186803b1580156102f457600080fd5b505afa158015610308573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061032c9190610770565b905060008111156103e6578773ffffffffffffffffffffffffffffffffffffffff1663a9059cbb60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b81526004016103929291906108e4565b602060405180830381600087803b1580156103ac57600080fd5b505af11580156103c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103e49190610743565b505b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167f29c40793bffd84cb810179f15d1ceec72bc7f0785514c668ba36645cf99b73828888886040516104479392919061096a565b60405180910390a3819250505095945050505050565b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60606000808573ffffffffffffffffffffffffffffffffffffffff163486866040516104f1929190610887565b60006040518083038185875af1925050503d806000811461052e576040519150601f19603f3d011682016040523d82523d6000602084013e610533565b606091505b509150915081610578576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161056f9061094a565b60405180910390fd5b80925050509392505050565b60008135905061059381610af9565b92915050565b6000815190506105a881610b10565b92915050565b60008083601f8401126105c4576105c3610aab565b5b8235905067ffffffffffffffff8111156105e1576105e0610aa6565b5b6020830191508360018202830111156105fd576105fc610ab0565b5b9250929050565b60008135905061061381610b27565b92915050565b60008151905061062881610b27565b92915050565b60006020828403121561064457610643610aba565b5b600061065284828501610584565b91505092915050565b60008060008060006080868803121561067757610676610aba565b5b600061068588828901610584565b955050602061069688828901610584565b94505060406106a788828901610604565b935050606086013567ffffffffffffffff8111156106c8576106c7610ab5565b5b6106d4888289016105ae565b92509250509295509295909350565b6000806000604084860312156106fc576106fb610aba565b5b600061070a86828701610584565b935050602084013567ffffffffffffffff81111561072b5761072a610ab5565b5b610737868287016105ae565b92509250509250925092565b60006020828403121561075957610758610aba565b5b600061076784828501610599565b91505092915050565b60006020828403121561078657610785610aba565b5b600061079484828501610619565b91505092915050565b6107a6816109d4565b82525050565b60006107b883856109a7565b93506107c5838584610a64565b6107ce83610abf565b840190509392505050565b60006107e583856109b8565b93506107f2838584610a64565b82840190509392505050565b60006108098261099c565b61081381856109a7565b9350610823818560208601610a73565b61082c81610abf565b840191505092915050565b61084081610a1c565b82525050565b61084f81610a2e565b82525050565b6000610862600b836109c3565b915061086d82610ad0565b602082019050919050565b61088181610a12565b82525050565b60006108948284866107d9565b91508190509392505050565b60006020820190506108b5600083018461079d565b92915050565b60006040820190506108d0600083018561079d565b6108dd6020830184610846565b9392505050565b60006040820190506108f9600083018561079d565b6109066020830184610878565b9392505050565b6000602082019050818103600083015261092781846107fe565b905092915050565b60006020820190506109446000830184610837565b92915050565b6000602082019050818103600083015261096381610855565b9050919050565b600060408201905061097f6000830186610878565b81810360208301526109928184866107ac565b9050949350505050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b60006109df826109f2565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000610a2782610a40565b9050919050565b6000610a3982610a12565b9050919050565b6000610a4b82610a52565b9050919050565b6000610a5d826109f2565b9050919050565b82818337600083830152505050565b60005b83811015610a91578082015181840152602081019050610a76565b83811115610aa0576000848401525b50505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f43616c6c206661696c6564000000000000000000000000000000000000000000600082015250565b610b02816109d4565b8114610b0d57600080fd5b50565b610b19816109e6565b8114610b2457600080fd5b50565b610b3081610a12565b8114610b3b57600080fd5b5056fea2646970667358221220b7ca56a15d2b2ff5fa94491bdaf59465dd8a8a42b6b9b4f2c681577108e1907164736f6c63430008070033", } // GatewayABI is the input ABI used to generate the binding from. @@ -202,30 +202,103 @@ func (_Gateway *GatewayTransactorRaw) Transact(opts *bind.TransactOpts, method s return _Gateway.Contract.contract.Transact(opts, method, params...) } -// ForwardCall is a paid mutator transaction binding the contract method 0x22bee494. +// Custody is a free data retrieval call binding the contract method 0xdda79b75. // -// Solidity: function forwardCall(address destination, bytes data) payable returns(bytes) -func (_Gateway *GatewayTransactor) ForwardCall(opts *bind.TransactOpts, destination common.Address, data []byte) (*types.Transaction, error) { - return _Gateway.contract.Transact(opts, "forwardCall", destination, data) +// Solidity: function custody() view returns(address) +func (_Gateway *GatewayCaller) Custody(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Gateway.contract.Call(opts, &out, "custody") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + } -// ForwardCall is a paid mutator transaction binding the contract method 0x22bee494. +// Custody is a free data retrieval call binding the contract method 0xdda79b75. // -// Solidity: function forwardCall(address destination, bytes data) payable returns(bytes) -func (_Gateway *GatewaySession) ForwardCall(destination common.Address, data []byte) (*types.Transaction, error) { - return _Gateway.Contract.ForwardCall(&_Gateway.TransactOpts, destination, data) +// Solidity: function custody() view returns(address) +func (_Gateway *GatewaySession) Custody() (common.Address, error) { + return _Gateway.Contract.Custody(&_Gateway.CallOpts) } -// ForwardCall is a paid mutator transaction binding the contract method 0x22bee494. +// Custody is a free data retrieval call binding the contract method 0xdda79b75. // -// Solidity: function forwardCall(address destination, bytes data) payable returns(bytes) -func (_Gateway *GatewayTransactorSession) ForwardCall(destination common.Address, data []byte) (*types.Transaction, error) { - return _Gateway.Contract.ForwardCall(&_Gateway.TransactOpts, destination, data) +// Solidity: function custody() view returns(address) +func (_Gateway *GatewayCallerSession) Custody() (common.Address, error) { + return _Gateway.Contract.Custody(&_Gateway.CallOpts) } -// GatewayForwardedIterator is returned from FilterForwarded and is used to iterate over the raw logs and unpacked data for Forwarded events raised by the Gateway contract. -type GatewayForwardedIterator struct { - Event *GatewayForwarded // Event containing the contract specifics and raw log +// Execute is a paid mutator transaction binding the contract method 0x1cff79cd. +// +// Solidity: function execute(address destination, bytes data) payable returns(bytes) +func (_Gateway *GatewayTransactor) Execute(opts *bind.TransactOpts, destination common.Address, data []byte) (*types.Transaction, error) { + return _Gateway.contract.Transact(opts, "execute", destination, data) +} + +// Execute is a paid mutator transaction binding the contract method 0x1cff79cd. +// +// Solidity: function execute(address destination, bytes data) payable returns(bytes) +func (_Gateway *GatewaySession) Execute(destination common.Address, data []byte) (*types.Transaction, error) { + return _Gateway.Contract.Execute(&_Gateway.TransactOpts, destination, data) +} + +// Execute is a paid mutator transaction binding the contract method 0x1cff79cd. +// +// Solidity: function execute(address destination, bytes data) payable returns(bytes) +func (_Gateway *GatewayTransactorSession) Execute(destination common.Address, data []byte) (*types.Transaction, error) { + return _Gateway.Contract.Execute(&_Gateway.TransactOpts, destination, data) +} + +// ExecuteWithERC20 is a paid mutator transaction binding the contract method 0x5131ab59. +// +// Solidity: function executeWithERC20(address token, address to, uint256 amount, bytes data) returns(bytes) +func (_Gateway *GatewayTransactor) ExecuteWithERC20(opts *bind.TransactOpts, token common.Address, to common.Address, amount *big.Int, data []byte) (*types.Transaction, error) { + return _Gateway.contract.Transact(opts, "executeWithERC20", token, to, amount, data) +} + +// ExecuteWithERC20 is a paid mutator transaction binding the contract method 0x5131ab59. +// +// Solidity: function executeWithERC20(address token, address to, uint256 amount, bytes data) returns(bytes) +func (_Gateway *GatewaySession) ExecuteWithERC20(token common.Address, to common.Address, amount *big.Int, data []byte) (*types.Transaction, error) { + return _Gateway.Contract.ExecuteWithERC20(&_Gateway.TransactOpts, token, to, amount, data) +} + +// ExecuteWithERC20 is a paid mutator transaction binding the contract method 0x5131ab59. +// +// Solidity: function executeWithERC20(address token, address to, uint256 amount, bytes data) returns(bytes) +func (_Gateway *GatewayTransactorSession) ExecuteWithERC20(token common.Address, to common.Address, amount *big.Int, data []byte) (*types.Transaction, error) { + return _Gateway.Contract.ExecuteWithERC20(&_Gateway.TransactOpts, token, to, amount, data) +} + +// SetCustody is a paid mutator transaction binding the contract method 0xae7a3a6f. +// +// Solidity: function setCustody(address _custody) returns() +func (_Gateway *GatewayTransactor) SetCustody(opts *bind.TransactOpts, _custody common.Address) (*types.Transaction, error) { + return _Gateway.contract.Transact(opts, "setCustody", _custody) +} + +// SetCustody is a paid mutator transaction binding the contract method 0xae7a3a6f. +// +// Solidity: function setCustody(address _custody) returns() +func (_Gateway *GatewaySession) SetCustody(_custody common.Address) (*types.Transaction, error) { + return _Gateway.Contract.SetCustody(&_Gateway.TransactOpts, _custody) +} + +// SetCustody is a paid mutator transaction binding the contract method 0xae7a3a6f. +// +// Solidity: function setCustody(address _custody) returns() +func (_Gateway *GatewayTransactorSession) SetCustody(_custody common.Address) (*types.Transaction, error) { + return _Gateway.Contract.SetCustody(&_Gateway.TransactOpts, _custody) +} + +// GatewayExecutedIterator is returned from FilterExecuted and is used to iterate over the raw logs and unpacked data for Executed events raised by the Gateway contract. +type GatewayExecutedIterator struct { + Event *GatewayExecuted // 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 @@ -239,7 +312,7 @@ type GatewayForwardedIterator struct { // 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 *GatewayForwardedIterator) Next() bool { +func (it *GatewayExecutedIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -248,7 +321,7 @@ func (it *GatewayForwardedIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(GatewayForwarded) + it.Event = new(GatewayExecuted) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -263,7 +336,7 @@ func (it *GatewayForwardedIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(GatewayForwarded) + it.Event = new(GatewayExecuted) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -279,53 +352,208 @@ func (it *GatewayForwardedIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *GatewayForwardedIterator) Error() error { +func (it *GatewayExecutedIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *GatewayForwardedIterator) Close() error { +func (it *GatewayExecutedIterator) Close() error { it.sub.Unsubscribe() return nil } -// GatewayForwarded represents a Forwarded event raised by the Gateway contract. -type GatewayForwarded struct { +// GatewayExecuted represents a Executed event raised by the Gateway contract. +type GatewayExecuted struct { Destination common.Address Value *big.Int Data []byte Raw types.Log // Blockchain specific contextual infos } -// FilterForwarded is a free log retrieval operation binding the contract event 0xc1de93dfa06362c6a616cde73ec17d116c0d588dd1df70f27f91b500de207c41. +// FilterExecuted is a free log retrieval operation binding the contract event 0xcaf938de11c367272220bfd1d2baa99ca46665e7bc4d85f00adb51b90fe1fa9f. // -// Solidity: event Forwarded(address indexed destination, uint256 value, bytes data) -func (_Gateway *GatewayFilterer) FilterForwarded(opts *bind.FilterOpts, destination []common.Address) (*GatewayForwardedIterator, error) { +// Solidity: event Executed(address indexed destination, uint256 value, bytes data) +func (_Gateway *GatewayFilterer) FilterExecuted(opts *bind.FilterOpts, destination []common.Address) (*GatewayExecutedIterator, error) { var destinationRule []interface{} for _, destinationItem := range destination { destinationRule = append(destinationRule, destinationItem) } - logs, sub, err := _Gateway.contract.FilterLogs(opts, "Forwarded", destinationRule) + logs, sub, err := _Gateway.contract.FilterLogs(opts, "Executed", destinationRule) if err != nil { return nil, err } - return &GatewayForwardedIterator{contract: _Gateway.contract, event: "Forwarded", logs: logs, sub: sub}, nil + return &GatewayExecutedIterator{contract: _Gateway.contract, event: "Executed", logs: logs, sub: sub}, nil } -// WatchForwarded is a free log subscription operation binding the contract event 0xc1de93dfa06362c6a616cde73ec17d116c0d588dd1df70f27f91b500de207c41. +// WatchExecuted is a free log subscription operation binding the contract event 0xcaf938de11c367272220bfd1d2baa99ca46665e7bc4d85f00adb51b90fe1fa9f. // -// Solidity: event Forwarded(address indexed destination, uint256 value, bytes data) -func (_Gateway *GatewayFilterer) WatchForwarded(opts *bind.WatchOpts, sink chan<- *GatewayForwarded, destination []common.Address) (event.Subscription, error) { +// Solidity: event Executed(address indexed destination, uint256 value, bytes data) +func (_Gateway *GatewayFilterer) WatchExecuted(opts *bind.WatchOpts, sink chan<- *GatewayExecuted, destination []common.Address) (event.Subscription, error) { var destinationRule []interface{} for _, destinationItem := range destination { destinationRule = append(destinationRule, destinationItem) } - logs, sub, err := _Gateway.contract.WatchLogs(opts, "Forwarded", destinationRule) + logs, sub, err := _Gateway.contract.WatchLogs(opts, "Executed", destinationRule) + 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(GatewayExecuted) + if err := _Gateway.contract.UnpackLog(event, "Executed", 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 +} + +// ParseExecuted is a log parse operation binding the contract event 0xcaf938de11c367272220bfd1d2baa99ca46665e7bc4d85f00adb51b90fe1fa9f. +// +// Solidity: event Executed(address indexed destination, uint256 value, bytes data) +func (_Gateway *GatewayFilterer) ParseExecuted(log types.Log) (*GatewayExecuted, error) { + event := new(GatewayExecuted) + if err := _Gateway.contract.UnpackLog(event, "Executed", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// GatewayExecutedWithERC20Iterator is returned from FilterExecutedWithERC20 and is used to iterate over the raw logs and unpacked data for ExecutedWithERC20 events raised by the Gateway contract. +type GatewayExecutedWithERC20Iterator struct { + Event *GatewayExecutedWithERC20 // 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 *GatewayExecutedWithERC20Iterator) 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(GatewayExecutedWithERC20) + 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(GatewayExecutedWithERC20) + 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 *GatewayExecutedWithERC20Iterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *GatewayExecutedWithERC20Iterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// GatewayExecutedWithERC20 represents a ExecutedWithERC20 event raised by the Gateway contract. +type GatewayExecutedWithERC20 struct { + Token common.Address + To common.Address + Amount *big.Int + Data []byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterExecutedWithERC20 is a free log retrieval operation binding the contract event 0x29c40793bffd84cb810179f15d1ceec72bc7f0785514c668ba36645cf99b7382. +// +// Solidity: event ExecutedWithERC20(address indexed token, address indexed to, uint256 amount, bytes data) +func (_Gateway *GatewayFilterer) FilterExecutedWithERC20(opts *bind.FilterOpts, token []common.Address, to []common.Address) (*GatewayExecutedWithERC20Iterator, error) { + + var tokenRule []interface{} + for _, tokenItem := range token { + tokenRule = append(tokenRule, tokenItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _Gateway.contract.FilterLogs(opts, "ExecutedWithERC20", tokenRule, toRule) + if err != nil { + return nil, err + } + return &GatewayExecutedWithERC20Iterator{contract: _Gateway.contract, event: "ExecutedWithERC20", logs: logs, sub: sub}, nil +} + +// WatchExecutedWithERC20 is a free log subscription operation binding the contract event 0x29c40793bffd84cb810179f15d1ceec72bc7f0785514c668ba36645cf99b7382. +// +// Solidity: event ExecutedWithERC20(address indexed token, address indexed to, uint256 amount, bytes data) +func (_Gateway *GatewayFilterer) WatchExecutedWithERC20(opts *bind.WatchOpts, sink chan<- *GatewayExecutedWithERC20, token []common.Address, to []common.Address) (event.Subscription, error) { + + var tokenRule []interface{} + for _, tokenItem := range token { + tokenRule = append(tokenRule, tokenItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _Gateway.contract.WatchLogs(opts, "ExecutedWithERC20", tokenRule, toRule) if err != nil { return nil, err } @@ -335,8 +563,8 @@ func (_Gateway *GatewayFilterer) WatchForwarded(opts *bind.WatchOpts, sink chan< select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(GatewayForwarded) - if err := _Gateway.contract.UnpackLog(event, "Forwarded", log); err != nil { + event := new(GatewayExecutedWithERC20) + if err := _Gateway.contract.UnpackLog(event, "ExecutedWithERC20", log); err != nil { return err } event.Raw = log @@ -357,12 +585,12 @@ func (_Gateway *GatewayFilterer) WatchForwarded(opts *bind.WatchOpts, sink chan< }), nil } -// ParseForwarded is a log parse operation binding the contract event 0xc1de93dfa06362c6a616cde73ec17d116c0d588dd1df70f27f91b500de207c41. +// ParseExecutedWithERC20 is a log parse operation binding the contract event 0x29c40793bffd84cb810179f15d1ceec72bc7f0785514c668ba36645cf99b7382. // -// Solidity: event Forwarded(address indexed destination, uint256 value, bytes data) -func (_Gateway *GatewayFilterer) ParseForwarded(log types.Log) (*GatewayForwarded, error) { - event := new(GatewayForwarded) - if err := _Gateway.contract.UnpackLog(event, "Forwarded", log); err != nil { +// Solidity: event ExecutedWithERC20(address indexed token, address indexed to, uint256 amount, bytes data) +func (_Gateway *GatewayFilterer) ParseExecutedWithERC20(log types.Log) (*GatewayExecutedWithERC20, error) { + event := new(GatewayExecutedWithERC20) + if err := _Gateway.contract.UnpackLog(event, "ExecutedWithERC20", log); err != nil { return nil, err } event.Raw = log diff --git a/pkg/contracts/prototypes/receiver.sol/receiver.go b/pkg/contracts/prototypes/receiver.sol/receiver.go index 19b4531c..8e04e47c 100644 --- a/pkg/contracts/prototypes/receiver.sol/receiver.go +++ b/pkg/contracts/prototypes/receiver.sol/receiver.go @@ -31,8 +31,8 @@ var ( // ReceiverMetaData contains all meta data concerning the Receiver contract. var ReceiverMetaData = &bind.MetaData{ - ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"str\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"num\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"flag\",\"type\":\"bool\"}],\"name\":\"ReceivedA\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string[]\",\"name\":\"strs\",\"type\":\"string[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"nums\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"flag\",\"type\":\"bool\"}],\"name\":\"ReceivedB\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"str\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"num\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"flag\",\"type\":\"bool\"}],\"name\":\"receiveA\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string[]\",\"name\":\"strs\",\"type\":\"string[]\"},{\"internalType\":\"uint256[]\",\"name\":\"nums\",\"type\":\"uint256[]\"},{\"internalType\":\"bool\",\"name\":\"flag\",\"type\":\"bool\"}],\"name\":\"receiveB\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x608060405234801561001057600080fd5b50610906806100206000396000f3fe6080604052600436106100295760003560e01c80636fa220ad1461002e578063f5db6b391461004a575b600080fd5b61004860048036038101906100439190610378565b610073565b005b34801561005657600080fd5b50610071600480360381019061006c91906102ed565b6100b7565b005b7f87d67858b5cc03bdd16a3fcc56773bd59410e946cff7193cf374402c6e8fb6ee33348585856040516100aa9594939291906105e7565b60405180910390a1505050565b7f463b3e5d6969d17b19e10c4ca95f5f1b6fdef8678f980af98071bd38f0d885c2338484846040516100ec9493929190610594565b60405180910390a1505050565b600061010c61010784610666565b610641565b9050808382526020820190508285602086028201111561012f5761012e61087d565b5b60005b8581101561017d57813567ffffffffffffffff81111561015557610154610878565b5b80860161016289826102aa565b85526020850194506020840193505050600181019050610132565b5050509392505050565b600061019a61019584610692565b610641565b905080838252602082019050828560208602820111156101bd576101bc61087d565b5b60005b858110156101ed57816101d388826102d8565b8452602084019350602083019250506001810190506101c0565b5050509392505050565b600061020a610205846106be565b610641565b90508281526020810184848401111561022657610225610882565b5b6102318482856107d6565b509392505050565b600082601f83011261024e5761024d610878565b5b813561025e8482602086016100f9565b91505092915050565b600082601f83011261027c5761027b610878565b5b813561028c848260208601610187565b91505092915050565b6000813590506102a4816108a2565b92915050565b600082601f8301126102bf576102be610878565b5b81356102cf8482602086016101f7565b91505092915050565b6000813590506102e7816108b9565b92915050565b6000806000606084860312156103065761030561088c565b5b600084013567ffffffffffffffff81111561032457610323610887565b5b61033086828701610239565b935050602084013567ffffffffffffffff81111561035157610350610887565b5b61035d86828701610267565b925050604061036e86828701610295565b9150509250925092565b6000806000606084860312156103915761039061088c565b5b600084013567ffffffffffffffff8111156103af576103ae610887565b5b6103bb868287016102aa565b93505060206103cc868287016102d8565b92505060406103dd86828701610295565b9150509250925092565b60006103f38383610504565b905092915050565b60006104078383610576565b60208301905092915050565b61041c8161078e565b82525050565b600061042d8261070f565b610437818561074a565b935083602082028501610449856106ef565b8060005b85811015610485578484038952815161046685826103e7565b945061047183610730565b925060208a0199505060018101905061044d565b50829750879550505050505092915050565b60006104a28261071a565b6104ac818561075b565b93506104b7836106ff565b8060005b838110156104e85781516104cf88826103fb565b97506104da8361073d565b9250506001810190506104bb565b5085935050505092915050565b6104fe816107a0565b82525050565b600061050f82610725565b610519818561076c565b93506105298185602086016107e5565b61053281610891565b840191505092915050565b600061054882610725565b610552818561077d565b93506105628185602086016107e5565b61056b81610891565b840191505092915050565b61057f816107cc565b82525050565b61058e816107cc565b82525050565b60006080820190506105a96000830187610413565b81810360208301526105bb8186610422565b905081810360408301526105cf8185610497565b90506105de60608301846104f5565b95945050505050565b600060a0820190506105fc6000830188610413565b6106096020830187610585565b818103604083015261061b818661053d565b905061062a6060830185610585565b61063760808301846104f5565b9695505050505050565b600061064b61065c565b90506106578282610818565b919050565b6000604051905090565b600067ffffffffffffffff82111561068157610680610849565b5b602082029050602081019050919050565b600067ffffffffffffffff8211156106ad576106ac610849565b5b602082029050602081019050919050565b600067ffffffffffffffff8211156106d9576106d8610849565b5b6106e282610891565b9050602081019050919050565b6000819050602082019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b6000610799826107ac565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b838110156108035780820151818401526020810190506107e8565b83811115610812576000848401525b50505050565b61082182610891565b810181811067ffffffffffffffff821117156108405761083f610849565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b6108ab816107a0565b81146108b657600080fd5b50565b6108c2816107cc565b81146108cd57600080fd5b5056fea2646970667358221220a471fde0547689c02df444b3d3f058d18c9dd15c58325e79133a63a1cc3608dd64736f6c63430008070033", + ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"str\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"num\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"flag\",\"type\":\"bool\"}],\"name\":\"ReceivedA\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string[]\",\"name\":\"strs\",\"type\":\"string[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"nums\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"flag\",\"type\":\"bool\"}],\"name\":\"ReceivedB\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"destination\",\"type\":\"address\"}],\"name\":\"ReceivedC\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"ReceivedD\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"str\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"num\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"flag\",\"type\":\"bool\"}],\"name\":\"receiveA\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string[]\",\"name\":\"strs\",\"type\":\"string[]\"},{\"internalType\":\"uint256[]\",\"name\":\"nums\",\"type\":\"uint256[]\"},{\"internalType\":\"bool\",\"name\":\"flag\",\"type\":\"bool\"}],\"name\":\"receiveB\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"destination\",\"type\":\"address\"}],\"name\":\"receiveC\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"receiveD\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x608060405234801561001057600080fd5b50610bbf806100206000396000f3fe60806040526004361061003f5760003560e01c806352df08b6146100445780636fa220ad1461006d57806386c4519214610089578063f5db6b39146100a0575b600080fd5b34801561005057600080fd5b5061006b6004803603810190610066919061059f565b6100c9565b005b61008760048036038101906100829190610530565b61019b565b005b34801561009557600080fd5b5061009e6101df565b005b3480156100ac57600080fd5b506100c760048036038101906100c29190610478565b610218565b005b8173ffffffffffffffffffffffffffffffffffffffff166323b872dd3383866040518463ffffffff1660e01b8152600401610106939291906107ba565b602060405180830381600087803b15801561012057600080fd5b505af1158015610134573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101589190610503565b507fe8077791e8d0f63b9e4c0b6d386cbbf6c65e1acb2a103019edba9d1cc0b329003384848460405161018e9493929190610844565b60405180910390a1505050565b7f87d67858b5cc03bdd16a3fcc56773bd59410e946cff7193cf374402c6e8fb6ee33348585856040516101d2959493929190610889565b60405180910390a1505050565b7fcf0e6f18d967cb5a3ca7781d74b1d66411d1b8984e2dd2a066709c204a66d8623360405161020e919061079f565b60405180910390a1565b7f463b3e5d6969d17b19e10c4ca95f5f1b6fdef8678f980af98071bd38f0d885c23384848460405161024d94939291906107f1565b60405180910390a1505050565b600061026d61026884610908565b6108e3565b905080838252602082019050828560208602820111156102905761028f610b1f565b5b60005b858110156102de57813567ffffffffffffffff8111156102b6576102b5610b1a565b5b8086016102c38982610435565b85526020850194506020840193505050600181019050610293565b5050509392505050565b60006102fb6102f684610934565b6108e3565b9050808382526020820190508285602086028201111561031e5761031d610b1f565b5b60005b8581101561034e57816103348882610463565b845260208401935060208301925050600181019050610321565b5050509392505050565b600061036b61036684610960565b6108e3565b90508281526020810184848401111561038757610386610b24565b5b610392848285610a78565b509392505050565b6000813590506103a981610b44565b92915050565b600082601f8301126103c4576103c3610b1a565b5b81356103d484826020860161025a565b91505092915050565b600082601f8301126103f2576103f1610b1a565b5b81356104028482602086016102e8565b91505092915050565b60008135905061041a81610b5b565b92915050565b60008151905061042f81610b5b565b92915050565b600082601f83011261044a57610449610b1a565b5b813561045a848260208601610358565b91505092915050565b60008135905061047281610b72565b92915050565b60008060006060848603121561049157610490610b2e565b5b600084013567ffffffffffffffff8111156104af576104ae610b29565b5b6104bb868287016103af565b935050602084013567ffffffffffffffff8111156104dc576104db610b29565b5b6104e8868287016103dd565b92505060406104f98682870161040b565b9150509250925092565b60006020828403121561051957610518610b2e565b5b600061052784828501610420565b91505092915050565b60008060006060848603121561054957610548610b2e565b5b600084013567ffffffffffffffff81111561056757610566610b29565b5b61057386828701610435565b935050602061058486828701610463565b92505060406105958682870161040b565b9150509250925092565b6000806000606084860312156105b8576105b7610b2e565b5b60006105c686828701610463565b93505060206105d78682870161039a565b92505060406105e88682870161039a565b9150509250925092565b60006105fe838361070f565b905092915050565b60006106128383610781565b60208301905092915050565b61062781610a30565b82525050565b6000610638826109b1565b61064281856109ec565b93508360208202850161065485610991565b8060005b85811015610690578484038952815161067185826105f2565b945061067c836109d2565b925060208a01995050600181019050610658565b50829750879550505050505092915050565b60006106ad826109bc565b6106b781856109fd565b93506106c2836109a1565b8060005b838110156106f35781516106da8882610606565b97506106e5836109df565b9250506001810190506106c6565b5085935050505092915050565b61070981610a42565b82525050565b600061071a826109c7565b6107248185610a0e565b9350610734818560208601610a87565b61073d81610b33565b840191505092915050565b6000610753826109c7565b61075d8185610a1f565b935061076d818560208601610a87565b61077681610b33565b840191505092915050565b61078a81610a6e565b82525050565b61079981610a6e565b82525050565b60006020820190506107b4600083018461061e565b92915050565b60006060820190506107cf600083018661061e565b6107dc602083018561061e565b6107e96040830184610790565b949350505050565b6000608082019050610806600083018761061e565b8181036020830152610818818661062d565b9050818103604083015261082c81856106a2565b905061083b6060830184610700565b95945050505050565b6000608082019050610859600083018761061e565b6108666020830186610790565b610873604083018561061e565b610880606083018461061e565b95945050505050565b600060a08201905061089e600083018861061e565b6108ab6020830187610790565b81810360408301526108bd8186610748565b90506108cc6060830185610790565b6108d96080830184610700565b9695505050505050565b60006108ed6108fe565b90506108f98282610aba565b919050565b6000604051905090565b600067ffffffffffffffff82111561092357610922610aeb565b5b602082029050602081019050919050565b600067ffffffffffffffff82111561094f5761094e610aeb565b5b602082029050602081019050919050565b600067ffffffffffffffff82111561097b5761097a610aeb565b5b61098482610b33565b9050602081019050919050565b6000819050602082019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b6000610a3b82610a4e565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015610aa5578082015181840152602081019050610a8a565b83811115610ab4576000848401525b50505050565b610ac382610b33565b810181811067ffffffffffffffff82111715610ae257610ae1610aeb565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b610b4d81610a30565b8114610b5857600080fd5b50565b610b6481610a42565b8114610b6f57600080fd5b50565b610b7b81610a6e565b8114610b8657600080fd5b5056fea264697066735822122071e33ff7a639cea7ba0e3fa2cb4106a312f1b8080d32e972b0ef4823ad974cf264736f6c63430008070033", } // ReceiverABI is the input ABI used to generate the binding from. @@ -244,6 +244,48 @@ func (_Receiver *ReceiverTransactorSession) ReceiveB(strs []string, nums []*big. return _Receiver.Contract.ReceiveB(&_Receiver.TransactOpts, strs, nums, flag) } +// ReceiveC is a paid mutator transaction binding the contract method 0x52df08b6. +// +// Solidity: function receiveC(uint256 amount, address token, address destination) returns() +func (_Receiver *ReceiverTransactor) ReceiveC(opts *bind.TransactOpts, amount *big.Int, token common.Address, destination common.Address) (*types.Transaction, error) { + return _Receiver.contract.Transact(opts, "receiveC", amount, token, destination) +} + +// ReceiveC is a paid mutator transaction binding the contract method 0x52df08b6. +// +// Solidity: function receiveC(uint256 amount, address token, address destination) returns() +func (_Receiver *ReceiverSession) ReceiveC(amount *big.Int, token common.Address, destination common.Address) (*types.Transaction, error) { + return _Receiver.Contract.ReceiveC(&_Receiver.TransactOpts, amount, token, destination) +} + +// ReceiveC is a paid mutator transaction binding the contract method 0x52df08b6. +// +// Solidity: function receiveC(uint256 amount, address token, address destination) returns() +func (_Receiver *ReceiverTransactorSession) ReceiveC(amount *big.Int, token common.Address, destination common.Address) (*types.Transaction, error) { + return _Receiver.Contract.ReceiveC(&_Receiver.TransactOpts, amount, token, destination) +} + +// ReceiveD is a paid mutator transaction binding the contract method 0x86c45192. +// +// Solidity: function receiveD() returns() +func (_Receiver *ReceiverTransactor) ReceiveD(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Receiver.contract.Transact(opts, "receiveD") +} + +// ReceiveD is a paid mutator transaction binding the contract method 0x86c45192. +// +// Solidity: function receiveD() returns() +func (_Receiver *ReceiverSession) ReceiveD() (*types.Transaction, error) { + return _Receiver.Contract.ReceiveD(&_Receiver.TransactOpts) +} + +// ReceiveD is a paid mutator transaction binding the contract method 0x86c45192. +// +// Solidity: function receiveD() returns() +func (_Receiver *ReceiverTransactorSession) ReceiveD() (*types.Transaction, error) { + return _Receiver.Contract.ReceiveD(&_Receiver.TransactOpts) +} + // ReceiverReceivedAIterator is returned from FilterReceivedA and is used to iterate over the raw logs and unpacked data for ReceivedA events raised by the Receiver contract. type ReceiverReceivedAIterator struct { Event *ReceiverReceivedA // Event containing the contract specifics and raw log @@ -518,3 +560,274 @@ func (_Receiver *ReceiverFilterer) ParseReceivedB(log types.Log) (*ReceiverRecei event.Raw = log return event, nil } + +// ReceiverReceivedCIterator is returned from FilterReceivedC and is used to iterate over the raw logs and unpacked data for ReceivedC events raised by the Receiver contract. +type ReceiverReceivedCIterator struct { + Event *ReceiverReceivedC // 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 *ReceiverReceivedCIterator) 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(ReceiverReceivedC) + 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(ReceiverReceivedC) + 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 *ReceiverReceivedCIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ReceiverReceivedCIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ReceiverReceivedC represents a ReceivedC event raised by the Receiver contract. +type ReceiverReceivedC struct { + Sender common.Address + Amount *big.Int + Token common.Address + Destination common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterReceivedC is a free log retrieval operation binding the contract event 0xe8077791e8d0f63b9e4c0b6d386cbbf6c65e1acb2a103019edba9d1cc0b32900. +// +// Solidity: event ReceivedC(address sender, uint256 amount, address token, address destination) +func (_Receiver *ReceiverFilterer) FilterReceivedC(opts *bind.FilterOpts) (*ReceiverReceivedCIterator, error) { + + logs, sub, err := _Receiver.contract.FilterLogs(opts, "ReceivedC") + if err != nil { + return nil, err + } + return &ReceiverReceivedCIterator{contract: _Receiver.contract, event: "ReceivedC", logs: logs, sub: sub}, nil +} + +// WatchReceivedC is a free log subscription operation binding the contract event 0xe8077791e8d0f63b9e4c0b6d386cbbf6c65e1acb2a103019edba9d1cc0b32900. +// +// Solidity: event ReceivedC(address sender, uint256 amount, address token, address destination) +func (_Receiver *ReceiverFilterer) WatchReceivedC(opts *bind.WatchOpts, sink chan<- *ReceiverReceivedC) (event.Subscription, error) { + + logs, sub, err := _Receiver.contract.WatchLogs(opts, "ReceivedC") + 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(ReceiverReceivedC) + if err := _Receiver.contract.UnpackLog(event, "ReceivedC", 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 +} + +// ParseReceivedC is a log parse operation binding the contract event 0xe8077791e8d0f63b9e4c0b6d386cbbf6c65e1acb2a103019edba9d1cc0b32900. +// +// Solidity: event ReceivedC(address sender, uint256 amount, address token, address destination) +func (_Receiver *ReceiverFilterer) ParseReceivedC(log types.Log) (*ReceiverReceivedC, error) { + event := new(ReceiverReceivedC) + if err := _Receiver.contract.UnpackLog(event, "ReceivedC", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ReceiverReceivedDIterator is returned from FilterReceivedD and is used to iterate over the raw logs and unpacked data for ReceivedD events raised by the Receiver contract. +type ReceiverReceivedDIterator struct { + Event *ReceiverReceivedD // 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 *ReceiverReceivedDIterator) 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(ReceiverReceivedD) + 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(ReceiverReceivedD) + 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 *ReceiverReceivedDIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ReceiverReceivedDIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ReceiverReceivedD represents a ReceivedD event raised by the Receiver contract. +type ReceiverReceivedD struct { + Sender common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterReceivedD is a free log retrieval operation binding the contract event 0xcf0e6f18d967cb5a3ca7781d74b1d66411d1b8984e2dd2a066709c204a66d862. +// +// Solidity: event ReceivedD(address sender) +func (_Receiver *ReceiverFilterer) FilterReceivedD(opts *bind.FilterOpts) (*ReceiverReceivedDIterator, error) { + + logs, sub, err := _Receiver.contract.FilterLogs(opts, "ReceivedD") + if err != nil { + return nil, err + } + return &ReceiverReceivedDIterator{contract: _Receiver.contract, event: "ReceivedD", logs: logs, sub: sub}, nil +} + +// WatchReceivedD is a free log subscription operation binding the contract event 0xcf0e6f18d967cb5a3ca7781d74b1d66411d1b8984e2dd2a066709c204a66d862. +// +// Solidity: event ReceivedD(address sender) +func (_Receiver *ReceiverFilterer) WatchReceivedD(opts *bind.WatchOpts, sink chan<- *ReceiverReceivedD) (event.Subscription, error) { + + logs, sub, err := _Receiver.contract.WatchLogs(opts, "ReceivedD") + 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(ReceiverReceivedD) + if err := _Receiver.contract.UnpackLog(event, "ReceivedD", 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 +} + +// ParseReceivedD is a log parse operation binding the contract event 0xcf0e6f18d967cb5a3ca7781d74b1d66411d1b8984e2dd2a066709c204a66d862. +// +// Solidity: event ReceivedD(address sender) +func (_Receiver *ReceiverFilterer) ParseReceivedD(log types.Log) (*ReceiverReceivedD, error) { + event := new(ReceiverReceivedD) + if err := _Receiver.contract.UnpackLog(event, "ReceivedD", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/pkg/contracts/prototypes/testerc20.sol/testerc20.go b/pkg/contracts/prototypes/testerc20.sol/testerc20.go new file mode 100644 index 00000000..24a6d264 --- /dev/null +++ b/pkg/contracts/prototypes/testerc20.sol/testerc20.go @@ -0,0 +1,823 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package testerc20 + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/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 +) + +// TestERC20MetaData contains all meta data concerning the TestERC20 contract. +var TestERC20MetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"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\":\"amount\",\"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\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"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\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x60806040523480156200001157600080fd5b5060405162001813380380620018138339818101604052810190620000379190620001a3565b818181600390805190602001906200005192919062000075565b5080600490805190602001906200006a92919062000075565b5050505050620003ac565b8280546200008390620002bd565b90600052602060002090601f016020900481019282620000a75760008555620000f3565b82601f10620000c257805160ff1916838001178555620000f3565b82800160010185558215620000f3579182015b82811115620000f2578251825591602001919060010190620000d5565b5b50905062000102919062000106565b5090565b5b808211156200012157600081600090555060010162000107565b5090565b60006200013c620001368462000251565b62000228565b9050828152602081018484840111156200015b576200015a6200038c565b5b6200016884828562000287565b509392505050565b600082601f83011262000188576200018762000387565b5b81516200019a84826020860162000125565b91505092915050565b60008060408385031215620001bd57620001bc62000396565b5b600083015167ffffffffffffffff811115620001de57620001dd62000391565b5b620001ec8582860162000170565b925050602083015167ffffffffffffffff81111562000210576200020f62000391565b5b6200021e8582860162000170565b9150509250929050565b60006200023462000247565b9050620002428282620002f3565b919050565b6000604051905090565b600067ffffffffffffffff8211156200026f576200026e62000358565b5b6200027a826200039b565b9050602081019050919050565b60005b83811015620002a75780820151818401526020810190506200028a565b83811115620002b7576000848401525b50505050565b60006002820490506001821680620002d657607f821691505b60208210811415620002ed57620002ec62000329565b5b50919050565b620002fe826200039b565b810181811067ffffffffffffffff8211171562000320576200031f62000358565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b61145780620003bc6000396000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c806340c10f191161007157806340c10f19146101a357806370a08231146101bf57806395d89b41146101ef578063a457c2d71461020d578063a9059cbb1461023d578063dd62ed3e1461026d576100b4565b806306fdde03146100b9578063095ea7b3146100d757806318160ddd1461010757806323b872dd14610125578063313ce567146101555780633950935114610173575b600080fd5b6100c161029d565b6040516100ce9190610ecf565b60405180910390f35b6100f160048036038101906100ec9190610cf6565b61032f565b6040516100fe9190610eb4565b60405180910390f35b61010f610352565b60405161011c9190610ff1565b60405180910390f35b61013f600480360381019061013a9190610ca3565b61035c565b60405161014c9190610eb4565b60405180910390f35b61015d61038b565b60405161016a919061100c565b60405180910390f35b61018d60048036038101906101889190610cf6565b610394565b60405161019a9190610eb4565b60405180910390f35b6101bd60048036038101906101b89190610cf6565b6103cb565b005b6101d960048036038101906101d49190610c36565b6103d9565b6040516101e69190610ff1565b60405180910390f35b6101f7610421565b6040516102049190610ecf565b60405180910390f35b61022760048036038101906102229190610cf6565b6104b3565b6040516102349190610eb4565b60405180910390f35b61025760048036038101906102529190610cf6565b61052a565b6040516102649190610eb4565b60405180910390f35b61028760048036038101906102829190610c63565b61054d565b6040516102949190610ff1565b60405180910390f35b6060600380546102ac90611121565b80601f01602080910402602001604051908101604052809291908181526020018280546102d890611121565b80156103255780601f106102fa57610100808354040283529160200191610325565b820191906000526020600020905b81548152906001019060200180831161030857829003601f168201915b5050505050905090565b60008061033a6105d4565b90506103478185856105dc565b600191505092915050565b6000600254905090565b6000806103676105d4565b90506103748582856107a7565b61037f858585610833565b60019150509392505050565b60006012905090565b60008061039f6105d4565b90506103c08185856103b1858961054d565b6103bb9190611043565b6105dc565b600191505092915050565b6103d58282610aab565b5050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60606004805461043090611121565b80601f016020809104026020016040519081016040528092919081815260200182805461045c90611121565b80156104a95780601f1061047e576101008083540402835291602001916104a9565b820191906000526020600020905b81548152906001019060200180831161048c57829003601f168201915b5050505050905090565b6000806104be6105d4565b905060006104cc828661054d565b905083811015610511576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161050890610fb1565b60405180910390fd5b61051e82868684036105dc565b60019250505092915050565b6000806105356105d4565b9050610542818585610833565b600191505092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561064c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161064390610f91565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156106bc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106b390610f11565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161079a9190610ff1565b60405180910390a3505050565b60006107b3848461054d565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811461082d578181101561081f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161081690610f31565b60405180910390fd5b61082c84848484036105dc565b5b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156108a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161089a90610f71565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610913576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161090a90610ef1565b60405180910390fd5b61091e838383610c02565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156109a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161099b90610f51565b60405180910390fd5b8181036000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610a929190610ff1565b60405180910390a3610aa5848484610c07565b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610b1b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b1290610fd1565b60405180910390fd5b610b2760008383610c02565b8060026000828254610b399190611043565b92505081905550806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610bea9190610ff1565b60405180910390a3610bfe60008383610c07565b5050565b505050565b505050565b600081359050610c1b816113f3565b92915050565b600081359050610c308161140a565b92915050565b600060208284031215610c4c57610c4b6111b1565b5b6000610c5a84828501610c0c565b91505092915050565b60008060408385031215610c7a57610c796111b1565b5b6000610c8885828601610c0c565b9250506020610c9985828601610c0c565b9150509250929050565b600080600060608486031215610cbc57610cbb6111b1565b5b6000610cca86828701610c0c565b9350506020610cdb86828701610c0c565b9250506040610cec86828701610c21565b9150509250925092565b60008060408385031215610d0d57610d0c6111b1565b5b6000610d1b85828601610c0c565b9250506020610d2c85828601610c21565b9150509250929050565b610d3f816110ab565b82525050565b6000610d5082611027565b610d5a8185611032565b9350610d6a8185602086016110ee565b610d73816111b6565b840191505092915050565b6000610d8b602383611032565b9150610d96826111c7565b604082019050919050565b6000610dae602283611032565b9150610db982611216565b604082019050919050565b6000610dd1601d83611032565b9150610ddc82611265565b602082019050919050565b6000610df4602683611032565b9150610dff8261128e565b604082019050919050565b6000610e17602583611032565b9150610e22826112dd565b604082019050919050565b6000610e3a602483611032565b9150610e458261132c565b604082019050919050565b6000610e5d602583611032565b9150610e688261137b565b604082019050919050565b6000610e80601f83611032565b9150610e8b826113ca565b602082019050919050565b610e9f816110d7565b82525050565b610eae816110e1565b82525050565b6000602082019050610ec96000830184610d36565b92915050565b60006020820190508181036000830152610ee98184610d45565b905092915050565b60006020820190508181036000830152610f0a81610d7e565b9050919050565b60006020820190508181036000830152610f2a81610da1565b9050919050565b60006020820190508181036000830152610f4a81610dc4565b9050919050565b60006020820190508181036000830152610f6a81610de7565b9050919050565b60006020820190508181036000830152610f8a81610e0a565b9050919050565b60006020820190508181036000830152610faa81610e2d565b9050919050565b60006020820190508181036000830152610fca81610e50565b9050919050565b60006020820190508181036000830152610fea81610e73565b9050919050565b60006020820190506110066000830184610e96565b92915050565b60006020820190506110216000830184610ea5565b92915050565b600081519050919050565b600082825260208201905092915050565b600061104e826110d7565b9150611059836110d7565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561108e5761108d611153565b5b828201905092915050565b60006110a4826110b7565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b8381101561110c5780820151818401526020810190506110f1565b8381111561111b576000848401525b50505050565b6000600282049050600182168061113957607f821691505b6020821081141561114d5761114c611182565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600080fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000600082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300600082015250565b6113fc81611099565b811461140757600080fd5b50565b611413816110d7565b811461141e57600080fd5b5056fea2646970667358221220fbf11f91cf796c0a9cb08e9bb25ad1c8c2a857df80f7507d9fd3d5493eb4f35a64736f6c63430008070033", +} + +// TestERC20ABI is the input ABI used to generate the binding from. +// Deprecated: Use TestERC20MetaData.ABI instead. +var TestERC20ABI = TestERC20MetaData.ABI + +// TestERC20Bin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use TestERC20MetaData.Bin instead. +var TestERC20Bin = TestERC20MetaData.Bin + +// DeployTestERC20 deploys a new Ethereum contract, binding an instance of TestERC20 to it. +func DeployTestERC20(auth *bind.TransactOpts, backend bind.ContractBackend, name string, symbol string) (common.Address, *types.Transaction, *TestERC20, error) { + parsed, err := TestERC20MetaData.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(TestERC20Bin), backend, name, symbol) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &TestERC20{TestERC20Caller: TestERC20Caller{contract: contract}, TestERC20Transactor: TestERC20Transactor{contract: contract}, TestERC20Filterer: TestERC20Filterer{contract: contract}}, nil +} + +// TestERC20 is an auto generated Go binding around an Ethereum contract. +type TestERC20 struct { + TestERC20Caller // Read-only binding to the contract + TestERC20Transactor // Write-only binding to the contract + TestERC20Filterer // Log filterer for contract events +} + +// TestERC20Caller is an auto generated read-only Go binding around an Ethereum contract. +type TestERC20Caller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// TestERC20Transactor is an auto generated write-only Go binding around an Ethereum contract. +type TestERC20Transactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// TestERC20Filterer is an auto generated log filtering Go binding around an Ethereum contract events. +type TestERC20Filterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// TestERC20Session is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type TestERC20Session struct { + Contract *TestERC20 // 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 +} + +// TestERC20CallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type TestERC20CallerSession struct { + Contract *TestERC20Caller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// TestERC20TransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type TestERC20TransactorSession struct { + Contract *TestERC20Transactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// TestERC20Raw is an auto generated low-level Go binding around an Ethereum contract. +type TestERC20Raw struct { + Contract *TestERC20 // Generic contract binding to access the raw methods on +} + +// TestERC20CallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type TestERC20CallerRaw struct { + Contract *TestERC20Caller // Generic read-only contract binding to access the raw methods on +} + +// TestERC20TransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type TestERC20TransactorRaw struct { + Contract *TestERC20Transactor // Generic write-only contract binding to access the raw methods on +} + +// NewTestERC20 creates a new instance of TestERC20, bound to a specific deployed contract. +func NewTestERC20(address common.Address, backend bind.ContractBackend) (*TestERC20, error) { + contract, err := bindTestERC20(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &TestERC20{TestERC20Caller: TestERC20Caller{contract: contract}, TestERC20Transactor: TestERC20Transactor{contract: contract}, TestERC20Filterer: TestERC20Filterer{contract: contract}}, nil +} + +// NewTestERC20Caller creates a new read-only instance of TestERC20, bound to a specific deployed contract. +func NewTestERC20Caller(address common.Address, caller bind.ContractCaller) (*TestERC20Caller, error) { + contract, err := bindTestERC20(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &TestERC20Caller{contract: contract}, nil +} + +// NewTestERC20Transactor creates a new write-only instance of TestERC20, bound to a specific deployed contract. +func NewTestERC20Transactor(address common.Address, transactor bind.ContractTransactor) (*TestERC20Transactor, error) { + contract, err := bindTestERC20(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &TestERC20Transactor{contract: contract}, nil +} + +// NewTestERC20Filterer creates a new log filterer instance of TestERC20, bound to a specific deployed contract. +func NewTestERC20Filterer(address common.Address, filterer bind.ContractFilterer) (*TestERC20Filterer, error) { + contract, err := bindTestERC20(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &TestERC20Filterer{contract: contract}, nil +} + +// bindTestERC20 binds a generic wrapper to an already deployed contract. +func bindTestERC20(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := TestERC20MetaData.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 (_TestERC20 *TestERC20Raw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _TestERC20.Contract.TestERC20Caller.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 (_TestERC20 *TestERC20Raw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _TestERC20.Contract.TestERC20Transactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_TestERC20 *TestERC20Raw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _TestERC20.Contract.TestERC20Transactor.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 (_TestERC20 *TestERC20CallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _TestERC20.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 (_TestERC20 *TestERC20TransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _TestERC20.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_TestERC20 *TestERC20TransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _TestERC20.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 (_TestERC20 *TestERC20Caller) Allowance(opts *bind.CallOpts, owner common.Address, spender common.Address) (*big.Int, error) { + var out []interface{} + err := _TestERC20.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 (_TestERC20 *TestERC20Session) Allowance(owner common.Address, spender common.Address) (*big.Int, error) { + return _TestERC20.Contract.Allowance(&_TestERC20.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 (_TestERC20 *TestERC20CallerSession) Allowance(owner common.Address, spender common.Address) (*big.Int, error) { + return _TestERC20.Contract.Allowance(&_TestERC20.CallOpts, owner, spender) +} + +// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. +// +// Solidity: function balanceOf(address account) view returns(uint256) +func (_TestERC20 *TestERC20Caller) BalanceOf(opts *bind.CallOpts, account common.Address) (*big.Int, error) { + var out []interface{} + err := _TestERC20.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 (_TestERC20 *TestERC20Session) BalanceOf(account common.Address) (*big.Int, error) { + return _TestERC20.Contract.BalanceOf(&_TestERC20.CallOpts, account) +} + +// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. +// +// Solidity: function balanceOf(address account) view returns(uint256) +func (_TestERC20 *TestERC20CallerSession) BalanceOf(account common.Address) (*big.Int, error) { + return _TestERC20.Contract.BalanceOf(&_TestERC20.CallOpts, account) +} + +// Decimals is a free data retrieval call binding the contract method 0x313ce567. +// +// Solidity: function decimals() view returns(uint8) +func (_TestERC20 *TestERC20Caller) Decimals(opts *bind.CallOpts) (uint8, error) { + var out []interface{} + err := _TestERC20.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 (_TestERC20 *TestERC20Session) Decimals() (uint8, error) { + return _TestERC20.Contract.Decimals(&_TestERC20.CallOpts) +} + +// Decimals is a free data retrieval call binding the contract method 0x313ce567. +// +// Solidity: function decimals() view returns(uint8) +func (_TestERC20 *TestERC20CallerSession) Decimals() (uint8, error) { + return _TestERC20.Contract.Decimals(&_TestERC20.CallOpts) +} + +// Name is a free data retrieval call binding the contract method 0x06fdde03. +// +// Solidity: function name() view returns(string) +func (_TestERC20 *TestERC20Caller) Name(opts *bind.CallOpts) (string, error) { + var out []interface{} + err := _TestERC20.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 (_TestERC20 *TestERC20Session) Name() (string, error) { + return _TestERC20.Contract.Name(&_TestERC20.CallOpts) +} + +// Name is a free data retrieval call binding the contract method 0x06fdde03. +// +// Solidity: function name() view returns(string) +func (_TestERC20 *TestERC20CallerSession) Name() (string, error) { + return _TestERC20.Contract.Name(&_TestERC20.CallOpts) +} + +// Symbol is a free data retrieval call binding the contract method 0x95d89b41. +// +// Solidity: function symbol() view returns(string) +func (_TestERC20 *TestERC20Caller) Symbol(opts *bind.CallOpts) (string, error) { + var out []interface{} + err := _TestERC20.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 (_TestERC20 *TestERC20Session) Symbol() (string, error) { + return _TestERC20.Contract.Symbol(&_TestERC20.CallOpts) +} + +// Symbol is a free data retrieval call binding the contract method 0x95d89b41. +// +// Solidity: function symbol() view returns(string) +func (_TestERC20 *TestERC20CallerSession) Symbol() (string, error) { + return _TestERC20.Contract.Symbol(&_TestERC20.CallOpts) +} + +// TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. +// +// Solidity: function totalSupply() view returns(uint256) +func (_TestERC20 *TestERC20Caller) TotalSupply(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _TestERC20.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 (_TestERC20 *TestERC20Session) TotalSupply() (*big.Int, error) { + return _TestERC20.Contract.TotalSupply(&_TestERC20.CallOpts) +} + +// TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. +// +// Solidity: function totalSupply() view returns(uint256) +func (_TestERC20 *TestERC20CallerSession) TotalSupply() (*big.Int, error) { + return _TestERC20.Contract.TotalSupply(&_TestERC20.CallOpts) +} + +// Approve is a paid mutator transaction binding the contract method 0x095ea7b3. +// +// Solidity: function approve(address spender, uint256 amount) returns(bool) +func (_TestERC20 *TestERC20Transactor) Approve(opts *bind.TransactOpts, spender common.Address, amount *big.Int) (*types.Transaction, error) { + return _TestERC20.contract.Transact(opts, "approve", spender, amount) +} + +// Approve is a paid mutator transaction binding the contract method 0x095ea7b3. +// +// Solidity: function approve(address spender, uint256 amount) returns(bool) +func (_TestERC20 *TestERC20Session) Approve(spender common.Address, amount *big.Int) (*types.Transaction, error) { + return _TestERC20.Contract.Approve(&_TestERC20.TransactOpts, spender, amount) +} + +// Approve is a paid mutator transaction binding the contract method 0x095ea7b3. +// +// Solidity: function approve(address spender, uint256 amount) returns(bool) +func (_TestERC20 *TestERC20TransactorSession) Approve(spender common.Address, amount *big.Int) (*types.Transaction, error) { + return _TestERC20.Contract.Approve(&_TestERC20.TransactOpts, spender, amount) +} + +// DecreaseAllowance is a paid mutator transaction binding the contract method 0xa457c2d7. +// +// Solidity: function decreaseAllowance(address spender, uint256 subtractedValue) returns(bool) +func (_TestERC20 *TestERC20Transactor) DecreaseAllowance(opts *bind.TransactOpts, spender common.Address, subtractedValue *big.Int) (*types.Transaction, error) { + return _TestERC20.contract.Transact(opts, "decreaseAllowance", spender, subtractedValue) +} + +// DecreaseAllowance is a paid mutator transaction binding the contract method 0xa457c2d7. +// +// Solidity: function decreaseAllowance(address spender, uint256 subtractedValue) returns(bool) +func (_TestERC20 *TestERC20Session) DecreaseAllowance(spender common.Address, subtractedValue *big.Int) (*types.Transaction, error) { + return _TestERC20.Contract.DecreaseAllowance(&_TestERC20.TransactOpts, spender, subtractedValue) +} + +// DecreaseAllowance is a paid mutator transaction binding the contract method 0xa457c2d7. +// +// Solidity: function decreaseAllowance(address spender, uint256 subtractedValue) returns(bool) +func (_TestERC20 *TestERC20TransactorSession) DecreaseAllowance(spender common.Address, subtractedValue *big.Int) (*types.Transaction, error) { + return _TestERC20.Contract.DecreaseAllowance(&_TestERC20.TransactOpts, spender, subtractedValue) +} + +// IncreaseAllowance is a paid mutator transaction binding the contract method 0x39509351. +// +// Solidity: function increaseAllowance(address spender, uint256 addedValue) returns(bool) +func (_TestERC20 *TestERC20Transactor) IncreaseAllowance(opts *bind.TransactOpts, spender common.Address, addedValue *big.Int) (*types.Transaction, error) { + return _TestERC20.contract.Transact(opts, "increaseAllowance", spender, addedValue) +} + +// IncreaseAllowance is a paid mutator transaction binding the contract method 0x39509351. +// +// Solidity: function increaseAllowance(address spender, uint256 addedValue) returns(bool) +func (_TestERC20 *TestERC20Session) IncreaseAllowance(spender common.Address, addedValue *big.Int) (*types.Transaction, error) { + return _TestERC20.Contract.IncreaseAllowance(&_TestERC20.TransactOpts, spender, addedValue) +} + +// IncreaseAllowance is a paid mutator transaction binding the contract method 0x39509351. +// +// Solidity: function increaseAllowance(address spender, uint256 addedValue) returns(bool) +func (_TestERC20 *TestERC20TransactorSession) IncreaseAllowance(spender common.Address, addedValue *big.Int) (*types.Transaction, error) { + return _TestERC20.Contract.IncreaseAllowance(&_TestERC20.TransactOpts, spender, addedValue) +} + +// Mint is a paid mutator transaction binding the contract method 0x40c10f19. +// +// Solidity: function mint(address to, uint256 amount) returns() +func (_TestERC20 *TestERC20Transactor) Mint(opts *bind.TransactOpts, to common.Address, amount *big.Int) (*types.Transaction, error) { + return _TestERC20.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 (_TestERC20 *TestERC20Session) Mint(to common.Address, amount *big.Int) (*types.Transaction, error) { + return _TestERC20.Contract.Mint(&_TestERC20.TransactOpts, to, amount) +} + +// Mint is a paid mutator transaction binding the contract method 0x40c10f19. +// +// Solidity: function mint(address to, uint256 amount) returns() +func (_TestERC20 *TestERC20TransactorSession) Mint(to common.Address, amount *big.Int) (*types.Transaction, error) { + return _TestERC20.Contract.Mint(&_TestERC20.TransactOpts, to, amount) +} + +// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. +// +// Solidity: function transfer(address to, uint256 amount) returns(bool) +func (_TestERC20 *TestERC20Transactor) Transfer(opts *bind.TransactOpts, to common.Address, amount *big.Int) (*types.Transaction, error) { + return _TestERC20.contract.Transact(opts, "transfer", to, amount) +} + +// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. +// +// Solidity: function transfer(address to, uint256 amount) returns(bool) +func (_TestERC20 *TestERC20Session) Transfer(to common.Address, amount *big.Int) (*types.Transaction, error) { + return _TestERC20.Contract.Transfer(&_TestERC20.TransactOpts, to, amount) +} + +// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. +// +// Solidity: function transfer(address to, uint256 amount) returns(bool) +func (_TestERC20 *TestERC20TransactorSession) Transfer(to common.Address, amount *big.Int) (*types.Transaction, error) { + return _TestERC20.Contract.Transfer(&_TestERC20.TransactOpts, to, amount) +} + +// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. +// +// Solidity: function transferFrom(address from, address to, uint256 amount) returns(bool) +func (_TestERC20 *TestERC20Transactor) TransferFrom(opts *bind.TransactOpts, from common.Address, to common.Address, amount *big.Int) (*types.Transaction, error) { + return _TestERC20.contract.Transact(opts, "transferFrom", from, to, amount) +} + +// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. +// +// Solidity: function transferFrom(address from, address to, uint256 amount) returns(bool) +func (_TestERC20 *TestERC20Session) TransferFrom(from common.Address, to common.Address, amount *big.Int) (*types.Transaction, error) { + return _TestERC20.Contract.TransferFrom(&_TestERC20.TransactOpts, from, to, amount) +} + +// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. +// +// Solidity: function transferFrom(address from, address to, uint256 amount) returns(bool) +func (_TestERC20 *TestERC20TransactorSession) TransferFrom(from common.Address, to common.Address, amount *big.Int) (*types.Transaction, error) { + return _TestERC20.Contract.TransferFrom(&_TestERC20.TransactOpts, from, to, amount) +} + +// TestERC20ApprovalIterator is returned from FilterApproval and is used to iterate over the raw logs and unpacked data for Approval events raised by the TestERC20 contract. +type TestERC20ApprovalIterator struct { + Event *TestERC20Approval // 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 *TestERC20ApprovalIterator) 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(TestERC20Approval) + 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(TestERC20Approval) + 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 *TestERC20ApprovalIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *TestERC20ApprovalIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// TestERC20Approval represents a Approval event raised by the TestERC20 contract. +type TestERC20Approval 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 (_TestERC20 *TestERC20Filterer) FilterApproval(opts *bind.FilterOpts, owner []common.Address, spender []common.Address) (*TestERC20ApprovalIterator, 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 := _TestERC20.contract.FilterLogs(opts, "Approval", ownerRule, spenderRule) + if err != nil { + return nil, err + } + return &TestERC20ApprovalIterator{contract: _TestERC20.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 (_TestERC20 *TestERC20Filterer) WatchApproval(opts *bind.WatchOpts, sink chan<- *TestERC20Approval, 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 := _TestERC20.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(TestERC20Approval) + if err := _TestERC20.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 (_TestERC20 *TestERC20Filterer) ParseApproval(log types.Log) (*TestERC20Approval, error) { + event := new(TestERC20Approval) + if err := _TestERC20.contract.UnpackLog(event, "Approval", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// TestERC20TransferIterator is returned from FilterTransfer and is used to iterate over the raw logs and unpacked data for Transfer events raised by the TestERC20 contract. +type TestERC20TransferIterator struct { + Event *TestERC20Transfer // 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 *TestERC20TransferIterator) 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(TestERC20Transfer) + 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(TestERC20Transfer) + 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 *TestERC20TransferIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *TestERC20TransferIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// TestERC20Transfer represents a Transfer event raised by the TestERC20 contract. +type TestERC20Transfer 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 (_TestERC20 *TestERC20Filterer) FilterTransfer(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*TestERC20TransferIterator, 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 := _TestERC20.contract.FilterLogs(opts, "Transfer", fromRule, toRule) + if err != nil { + return nil, err + } + return &TestERC20TransferIterator{contract: _TestERC20.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 (_TestERC20 *TestERC20Filterer) WatchTransfer(opts *bind.WatchOpts, sink chan<- *TestERC20Transfer, 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 := _TestERC20.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(TestERC20Transfer) + if err := _TestERC20.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 (_TestERC20 *TestERC20Filterer) ParseTransfer(log types.Log) (*TestERC20Transfer, error) { + event := new(TestERC20Transfer) + if err := _TestERC20.contract.UnpackLog(event, "Transfer", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/test/prototypes/GatewayIntegration.spec.ts b/test/prototypes/GatewayIntegration.spec.ts index 40917f2e..ace6bb30 100644 --- a/test/prototypes/GatewayIntegration.spec.ts +++ b/test/prototypes/GatewayIntegration.spec.ts @@ -3,118 +3,120 @@ import { Contract } from "ethers"; import { ethers } from "hardhat"; describe("Gateway and Receiver", function () { - let receiver: Contract; - let gateway: Contract; - let token: Contract; - let custody: Contract; - let owner: any, destination: any; - - beforeEach(async function () { - const TestERC20 = await ethers.getContractFactory("TestERC20"); - const Receiver = await ethers.getContractFactory("Receiver"); - const Gateway = await ethers.getContractFactory("Gateway"); - const Custody = await ethers.getContractFactory("ERC20CustodyNew"); - [owner, destination] = await ethers.getSigners(); - - // Deploy the contracts - token = await TestERC20.deploy("Test Token", "TTK"); - receiver = await Receiver.deploy(); - gateway = await Gateway.deploy(); - custody = await Custody.deploy(gateway.address); - - gateway.setCustody(custody.address); - - // Mint initial supply to the owner - await token.mint(owner.address, ethers.utils.parseEther("1000")); - - // Transfer some tokens to the custody contract - await token.transfer(custody.address, ethers.utils.parseEther("500")); - }); - - it("should forward call to Receiver's receiveA function", async function () { - const str = "Hello, Hardhat!"; - const num = 42; - const flag = true; - const value = ethers.utils.parseEther("1.0"); - - // Encode the function call data - const data = receiver.interface.encodeFunctionData("receiveA", [str, num, flag]); - - // Call execute on the Gateway contract - const tx = await gateway.execute(receiver.address, data, { value: value }); - await tx.wait(); - - // Listen for the event - await expect(tx).to.emit(receiver, "ReceivedA").withArgs(gateway.address, value, str, num, flag); - }); - - it("should forward call to Receiver's receiveB function", async function () { - const strs = ["Hello", "Hardhat"]; - const nums = [1, 2, 3]; - const flag = false; - const data = receiver.interface.encodeFunctionData("receiveB", [strs, nums, flag]); - const tx = await gateway.execute(receiver.address, data); - await tx.wait(); - await expect(tx).to.emit(receiver, "ReceivedB").withArgs(gateway.address, strs, nums, flag); - }); - - it("should forward call with withdrawAndCall and give allowance to destination contract", async function () { - const amount = ethers.utils.parseEther("100"); - - // Encode the function call data for receiveC - const data = receiver.interface.encodeFunctionData("receiveC", [amount, token.address, destination.address]); - - // Withdraw and call - const tx = await custody.withdrawAndCall(token.address, receiver.address, amount, data); - await tx.wait(); - - // Verify the event was emitted - await expect(tx).to.emit(receiver, "ReceivedC").withArgs(gateway.address, amount, token.address, destination.address); - - // Verify that the tokens were transferred to the destination address - const receiverBalance = await token.balanceOf(destination.address); - expect(receiverBalance).to.equal(amount); - - // Verify that the remaining tokens were refunded to the Custody contract - const remainingBalance = await token.balanceOf(custody.address); - expect(remainingBalance).to.equal(ethers.utils.parseEther("400")); - - // Verify that the approval was reset - const allowance = await token.allowance(gateway.address, receiver.address); - expect(allowance).to.equal(0); - }); - - it("should forward call to Receiver's receiveD function", async function () { - const data = receiver.interface.encodeFunctionData("receiveD"); - - // Execute the call - const tx = await gateway.execute(receiver.address, data); - await tx.wait(); - - // Verify the event was emitted - await expect(tx).to.emit(receiver, "ReceivedD").withArgs(gateway.address) - }); - - it("should forward call to Receiver's receiveD function through withdrawAndCall and return ERC20 tokens to custody", async function () { - const amount = ethers.utils.parseEther("100"); - - // Encode the function call data for receiveD - const data = receiver.interface.encodeFunctionData("receiveD"); - - // Withdraw and call - await custody.withdrawAndCall(token.address, receiver.address, amount, data); - - // Verify the event was emitted - await expect(custody.withdrawAndCall(token.address, receiver.address, amount, data)) - .to.emit(receiver, "ReceivedD") - .withArgs(gateway.address); - - // Verify that the remaining tokens were refunded to the Custody contract - const remainingBalance = await token.balanceOf(custody.address); - expect(remainingBalance).to.equal(ethers.utils.parseEther("500")); - - // Verify that the approval was reset - const allowance = await token.allowance(gateway.address, receiver.address); - expect(allowance).to.equal(0); - }); -}); \ No newline at end of file + let receiver: Contract; + let gateway: Contract; + let token: Contract; + let custody: Contract; + let owner: any, destination: any; + + beforeEach(async function () { + const TestERC20 = await ethers.getContractFactory("TestERC20"); + const Receiver = await ethers.getContractFactory("Receiver"); + const Gateway = await ethers.getContractFactory("Gateway"); + const Custody = await ethers.getContractFactory("ERC20CustodyNew"); + [owner, destination] = await ethers.getSigners(); + + // Deploy the contracts + token = await TestERC20.deploy("Test Token", "TTK"); + receiver = await Receiver.deploy(); + gateway = await Gateway.deploy(); + custody = await Custody.deploy(gateway.address); + + gateway.setCustody(custody.address); + + // Mint initial supply to the owner + await token.mint(owner.address, ethers.utils.parseEther("1000")); + + // Transfer some tokens to the custody contract + await token.transfer(custody.address, ethers.utils.parseEther("500")); + }); + + it("should forward call to Receiver's receiveA function", async function () { + const str = "Hello, Hardhat!"; + const num = 42; + const flag = true; + const value = ethers.utils.parseEther("1.0"); + + // Encode the function call data + const data = receiver.interface.encodeFunctionData("receiveA", [str, num, flag]); + + // Call execute on the Gateway contract + const tx = await gateway.execute(receiver.address, data, { value: value }); + await tx.wait(); + + // Listen for the event + await expect(tx).to.emit(receiver, "ReceivedA").withArgs(gateway.address, value, str, num, flag); + }); + + it("should forward call to Receiver's receiveB function", async function () { + const strs = ["Hello", "Hardhat"]; + const nums = [1, 2, 3]; + const flag = false; + const data = receiver.interface.encodeFunctionData("receiveB", [strs, nums, flag]); + const tx = await gateway.execute(receiver.address, data); + await tx.wait(); + await expect(tx).to.emit(receiver, "ReceivedB").withArgs(gateway.address, strs, nums, flag); + }); + + it("should forward call with withdrawAndCall and give allowance to destination contract", async function () { + const amount = ethers.utils.parseEther("100"); + + // Encode the function call data for receiveC + const data = receiver.interface.encodeFunctionData("receiveC", [amount, token.address, destination.address]); + + // Withdraw and call + const tx = await custody.withdrawAndCall(token.address, receiver.address, amount, data); + await tx.wait(); + + // Verify the event was emitted + await expect(tx) + .to.emit(receiver, "ReceivedC") + .withArgs(gateway.address, amount, token.address, destination.address); + + // Verify that the tokens were transferred to the destination address + const receiverBalance = await token.balanceOf(destination.address); + expect(receiverBalance).to.equal(amount); + + // Verify that the remaining tokens were refunded to the Custody contract + const remainingBalance = await token.balanceOf(custody.address); + expect(remainingBalance).to.equal(ethers.utils.parseEther("400")); + + // Verify that the approval was reset + const allowance = await token.allowance(gateway.address, receiver.address); + expect(allowance).to.equal(0); + }); + + it("should forward call to Receiver's receiveD function", async function () { + const data = receiver.interface.encodeFunctionData("receiveD"); + + // Execute the call + const tx = await gateway.execute(receiver.address, data); + await tx.wait(); + + // Verify the event was emitted + await expect(tx).to.emit(receiver, "ReceivedD").withArgs(gateway.address); + }); + + it("should forward call to Receiver's receiveD function through withdrawAndCall and return ERC20 tokens to custody", async function () { + const amount = ethers.utils.parseEther("100"); + + // Encode the function call data for receiveD + const data = receiver.interface.encodeFunctionData("receiveD"); + + // Withdraw and call + await custody.withdrawAndCall(token.address, receiver.address, amount, data); + + // Verify the event was emitted + await expect(custody.withdrawAndCall(token.address, receiver.address, amount, data)) + .to.emit(receiver, "ReceivedD") + .withArgs(gateway.address); + + // Verify that the remaining tokens were refunded to the Custody contract + const remainingBalance = await token.balanceOf(custody.address); + expect(remainingBalance).to.equal(ethers.utils.parseEther("500")); + + // Verify that the approval was reset + const allowance = await token.allowance(gateway.address, receiver.address); + expect(allowance).to.equal(0); + }); +}); diff --git a/test/prototypes/GatewayUniswap.spec.ts b/test/prototypes/GatewayUniswap.spec.ts index 909a52cf..42268dc7 100644 --- a/test/prototypes/GatewayUniswap.spec.ts +++ b/test/prototypes/GatewayUniswap.spec.ts @@ -1,91 +1,95 @@ import { expect } from "chai"; import { Contract } from "ethers"; import { ethers } from "hardhat"; -import { ERC20, ERC20CustodyNew, Gateway, Receiver, TestERC20, UniswapV2Factory, UniswapV2Pair, UniswapV2Router02 } from "../../typechain-types"; import { UniswapV2Deployer } from "uniswap-v2-deploy-plugin"; +import { + ERC20, + ERC20CustodyNew, + Gateway, + Receiver, + TestERC20, + UniswapV2Factory, + UniswapV2Pair, + UniswapV2Router02, +} from "../../typechain-types"; + describe("Uniswap Integration with Gateway", function () { - let tokenA: TestERC20; - let tokenB: TestERC20; - let factory: UniswapV2Factory; - let router: UniswapV2Router02; - let pair: UniswapV2Pair; - let custody: ERC20CustodyNew; - let gateway: Gateway; - let owner, addr1, addr2; - - beforeEach(async function () { - [owner, addr1, addr2] = await ethers.getSigners(); - - // Deploy TestERC20 tokens - const TestERC20 = await ethers.getContractFactory("TestERC20"); - tokenA = await TestERC20.deploy("Token A", "TKA") as TestERC20; - tokenB = await TestERC20.deploy("Token B", "TKB") as TestERC20; - await tokenA.mint(owner.address, ethers.utils.parseEther("1000")); - await tokenB.mint(owner.address, ethers.utils.parseEther("1000")); - - - const { - factory: newFactory, - router: newRouter, - weth9: weth - } = await UniswapV2Deployer.deploy(owner) - - factory = newFactory; - router = newRouter; - - // Approve Router to move tokens - await tokenA.approve(router.address, ethers.utils.parseEther("1000")); - await tokenB.approve(router.address, ethers.utils.parseEther("1000")); - - - // Add Liquidity - await router.addLiquidity( - tokenA.address, - tokenB.address, - ethers.utils.parseEther("500"), - ethers.utils.parseEther("500"), - 0, - 0, - owner.address, - Math.floor(Date.now() / 1000) + 60 * 20 - ); - - // Deploy Gateway and Custody Contracts - const Gateway = await ethers.getContractFactory("Gateway"); - const ERC20CustodyNew = await ethers.getContractFactory("ERC20CustodyNew"); - gateway = await Gateway.deploy() as Gateway; - custody = await ERC20CustodyNew.deploy(gateway.address) as ERC20CustodyNew; - - // Transfer some tokens to the custody contract - await tokenA.transfer(custody.address, ethers.utils.parseEther("100")); - await tokenB.transfer(custody.address, ethers.utils.parseEther("100")); - }); - - it("should perform a token swap on Uniswap and transfer the output tokens to a destination address", async function () { - const amountIn = ethers.utils.parseEther("50"); - - const data = router.interface.encodeFunctionData("swapExactTokensForTokens", [ - amountIn, - 0, - [tokenA.address, tokenB.address], - addr2.address, - Math.floor(Date.now() / 1000) + 60 * 20 - ]); - - // Withdraw and call - await custody.withdrawAndCall(tokenA.address, router.address, amountIn, data); - - // Verify the destination address received the tokens - const destBalance = await tokenB.balanceOf(addr2.address); - expect(destBalance).to.be.gt(0); - - // Verify the remaining tokens are refunded to the Custody contract - const remainingBalance = await tokenA.balanceOf(custody.address); - expect(remainingBalance).to.equal(ethers.utils.parseEther("50")); - - // Verify the approval was reset - const allowance = await tokenA.allowance(gateway.address, router.address); - expect(allowance).to.equal(0); - }); -}); \ No newline at end of file + let tokenA: TestERC20; + let tokenB: TestERC20; + let factory: UniswapV2Factory; + let router: UniswapV2Router02; + let pair: UniswapV2Pair; + let custody: ERC20CustodyNew; + let gateway: Gateway; + let owner, addr1, addr2; + + beforeEach(async function () { + [owner, addr1, addr2] = await ethers.getSigners(); + + // Deploy TestERC20 tokens + const TestERC20 = await ethers.getContractFactory("TestERC20"); + tokenA = (await TestERC20.deploy("Token A", "TKA")) as TestERC20; + tokenB = (await TestERC20.deploy("Token B", "TKB")) as TestERC20; + await tokenA.mint(owner.address, ethers.utils.parseEther("1000")); + await tokenB.mint(owner.address, ethers.utils.parseEther("1000")); + + const { factory: newFactory, router: newRouter, weth9: weth } = await UniswapV2Deployer.deploy(owner); + + factory = newFactory; + router = newRouter; + + // Approve Router to move tokens + await tokenA.approve(router.address, ethers.utils.parseEther("1000")); + await tokenB.approve(router.address, ethers.utils.parseEther("1000")); + + // Add Liquidity + await router.addLiquidity( + tokenA.address, + tokenB.address, + ethers.utils.parseEther("500"), + ethers.utils.parseEther("500"), + 0, + 0, + owner.address, + Math.floor(Date.now() / 1000) + 60 * 20 + ); + + // Deploy Gateway and Custody Contracts + const Gateway = await ethers.getContractFactory("Gateway"); + const ERC20CustodyNew = await ethers.getContractFactory("ERC20CustodyNew"); + gateway = (await Gateway.deploy()) as Gateway; + custody = (await ERC20CustodyNew.deploy(gateway.address)) as ERC20CustodyNew; + + // Transfer some tokens to the custody contract + await tokenA.transfer(custody.address, ethers.utils.parseEther("100")); + await tokenB.transfer(custody.address, ethers.utils.parseEther("100")); + }); + + it("should perform a token swap on Uniswap and transfer the output tokens to a destination address", async function () { + const amountIn = ethers.utils.parseEther("50"); + + const data = router.interface.encodeFunctionData("swapExactTokensForTokens", [ + amountIn, + 0, + [tokenA.address, tokenB.address], + addr2.address, + Math.floor(Date.now() / 1000) + 60 * 20, + ]); + + // Withdraw and call + await custody.withdrawAndCall(tokenA.address, router.address, amountIn, data); + + // Verify the destination address received the tokens + const destBalance = await tokenB.balanceOf(addr2.address); + expect(destBalance).to.be.gt(0); + + // Verify the remaining tokens are refunded to the Custody contract + const remainingBalance = await tokenA.balanceOf(custody.address); + expect(remainingBalance).to.equal(ethers.utils.parseEther("50")); + + // Verify the approval was reset + const allowance = await tokenA.allowance(gateway.address, router.address); + expect(allowance).to.equal(0); + }); +});