diff --git a/contract/IRefundCallback.go b/contract/IRefundCallback.go deleted file mode 100644 index 1375b3e5..00000000 --- a/contract/IRefundCallback.go +++ /dev/null @@ -1,202 +0,0 @@ -// Code generated - DO NOT EDIT. -// This file is a generated binding and any manual changes will be lost. - -package contract - -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 -) - -// IRefundCallbackMetaData contains all meta data concerning the IRefundCallback contract. -var IRefundCallbackMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_eventNonce\",\"type\":\"uint256\"},{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_amounts\",\"type\":\"uint256[]\"}],\"name\":\"refundCallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", -} - -// IRefundCallbackABI is the input ABI used to generate the binding from. -// Deprecated: Use IRefundCallbackMetaData.ABI instead. -var IRefundCallbackABI = IRefundCallbackMetaData.ABI - -// IRefundCallback is an auto generated Go binding around an Ethereum contract. -type IRefundCallback struct { - IRefundCallbackCaller // Read-only binding to the contract - IRefundCallbackTransactor // Write-only binding to the contract - IRefundCallbackFilterer // Log filterer for contract events -} - -// IRefundCallbackCaller is an auto generated read-only Go binding around an Ethereum contract. -type IRefundCallbackCaller struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// IRefundCallbackTransactor is an auto generated write-only Go binding around an Ethereum contract. -type IRefundCallbackTransactor struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// IRefundCallbackFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type IRefundCallbackFilterer struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// IRefundCallbackSession is an auto generated Go binding around an Ethereum contract, -// with pre-set call and transact options. -type IRefundCallbackSession struct { - Contract *IRefundCallback // 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 -} - -// IRefundCallbackCallerSession is an auto generated read-only Go binding around an Ethereum contract, -// with pre-set call options. -type IRefundCallbackCallerSession struct { - Contract *IRefundCallbackCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session -} - -// IRefundCallbackTransactorSession is an auto generated write-only Go binding around an Ethereum contract, -// with pre-set transact options. -type IRefundCallbackTransactorSession struct { - Contract *IRefundCallbackTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// IRefundCallbackRaw is an auto generated low-level Go binding around an Ethereum contract. -type IRefundCallbackRaw struct { - Contract *IRefundCallback // Generic contract binding to access the raw methods on -} - -// IRefundCallbackCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type IRefundCallbackCallerRaw struct { - Contract *IRefundCallbackCaller // Generic read-only contract binding to access the raw methods on -} - -// IRefundCallbackTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type IRefundCallbackTransactorRaw struct { - Contract *IRefundCallbackTransactor // Generic write-only contract binding to access the raw methods on -} - -// NewIRefundCallback creates a new instance of IRefundCallback, bound to a specific deployed contract. -func NewIRefundCallback(address common.Address, backend bind.ContractBackend) (*IRefundCallback, error) { - contract, err := bindIRefundCallback(address, backend, backend, backend) - if err != nil { - return nil, err - } - return &IRefundCallback{IRefundCallbackCaller: IRefundCallbackCaller{contract: contract}, IRefundCallbackTransactor: IRefundCallbackTransactor{contract: contract}, IRefundCallbackFilterer: IRefundCallbackFilterer{contract: contract}}, nil -} - -// NewIRefundCallbackCaller creates a new read-only instance of IRefundCallback, bound to a specific deployed contract. -func NewIRefundCallbackCaller(address common.Address, caller bind.ContractCaller) (*IRefundCallbackCaller, error) { - contract, err := bindIRefundCallback(address, caller, nil, nil) - if err != nil { - return nil, err - } - return &IRefundCallbackCaller{contract: contract}, nil -} - -// NewIRefundCallbackTransactor creates a new write-only instance of IRefundCallback, bound to a specific deployed contract. -func NewIRefundCallbackTransactor(address common.Address, transactor bind.ContractTransactor) (*IRefundCallbackTransactor, error) { - contract, err := bindIRefundCallback(address, nil, transactor, nil) - if err != nil { - return nil, err - } - return &IRefundCallbackTransactor{contract: contract}, nil -} - -// NewIRefundCallbackFilterer creates a new log filterer instance of IRefundCallback, bound to a specific deployed contract. -func NewIRefundCallbackFilterer(address common.Address, filterer bind.ContractFilterer) (*IRefundCallbackFilterer, error) { - contract, err := bindIRefundCallback(address, nil, nil, filterer) - if err != nil { - return nil, err - } - return &IRefundCallbackFilterer{contract: contract}, nil -} - -// bindIRefundCallback binds a generic wrapper to an already deployed contract. -func bindIRefundCallback(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := IRefundCallbackMetaData.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 (_IRefundCallback *IRefundCallbackRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _IRefundCallback.Contract.IRefundCallbackCaller.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 (_IRefundCallback *IRefundCallbackRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _IRefundCallback.Contract.IRefundCallbackTransactor.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_IRefundCallback *IRefundCallbackRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _IRefundCallback.Contract.IRefundCallbackTransactor.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 (_IRefundCallback *IRefundCallbackCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _IRefundCallback.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 (_IRefundCallback *IRefundCallbackTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _IRefundCallback.Contract.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_IRefundCallback *IRefundCallbackTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _IRefundCallback.Contract.contract.Transact(opts, method, params...) -} - -// RefundCallback is a paid mutator transaction binding the contract method 0x3a37fb2e. -// -// Solidity: function refundCallback(uint256 _eventNonce, address[] _tokens, uint256[] _amounts) returns() -func (_IRefundCallback *IRefundCallbackTransactor) RefundCallback(opts *bind.TransactOpts, _eventNonce *big.Int, _tokens []common.Address, _amounts []*big.Int) (*types.Transaction, error) { - return _IRefundCallback.contract.Transact(opts, "refundCallback", _eventNonce, _tokens, _amounts) -} - -// RefundCallback is a paid mutator transaction binding the contract method 0x3a37fb2e. -// -// Solidity: function refundCallback(uint256 _eventNonce, address[] _tokens, uint256[] _amounts) returns() -func (_IRefundCallback *IRefundCallbackSession) RefundCallback(_eventNonce *big.Int, _tokens []common.Address, _amounts []*big.Int) (*types.Transaction, error) { - return _IRefundCallback.Contract.RefundCallback(&_IRefundCallback.TransactOpts, _eventNonce, _tokens, _amounts) -} - -// RefundCallback is a paid mutator transaction binding the contract method 0x3a37fb2e. -// -// Solidity: function refundCallback(uint256 _eventNonce, address[] _tokens, uint256[] _amounts) returns() -func (_IRefundCallback *IRefundCallbackTransactorSession) RefundCallback(_eventNonce *big.Int, _tokens []common.Address, _amounts []*big.Int) (*types.Transaction, error) { - return _IRefundCallback.Contract.RefundCallback(&_IRefundCallback.TransactOpts, _eventNonce, _tokens, _amounts) -} diff --git a/contract/compile.sh b/contract/compile.sh index d5f4221b..ad2c0555 100755 --- a/contract/compile.sh +++ b/contract/compile.sh @@ -30,34 +30,24 @@ echo "===> Compiling contracts" [[ ! -d "$project_dir/contract/artifacts" ]] && mkdir -p "$project_dir/contract/artifacts" -# add core contracts -contracts=(WFXUpgradable FIP20Upgradable ICrosschain IStaking IFxBridgeLogic IBridgeCallback IError IBridgeFeeQuote) -contracts_test=(CrosschainTest StakingTest) -# add 3rd party contracts -contracts+=(ERC1967Proxy) -contracts_test+=(ERC721TokenTest) +contracts=(WFXUpgradable FIP20Upgradable IStaking IError ERC1967Proxy) +contracts+=(IFxBridgeLogic IBridgeCallback IBridgeFeeQuote ICrosschain) +contracts+=(CrosschainTest StakingTest ERC721TokenTest) for contract in "${contracts[@]}"; do echo "===> Ethereum ABI wrapper code generator: $contract" file_path=$(find "$project_dir/solidity/artifacts" -name "${contract}.json" -type f) jq -c '.abi' "$file_path" >"$project_dir/contract/artifacts/${contract}.abi" jq -r '.bytecode' "$file_path" >"$project_dir/contract/artifacts/${contract}.bin" + go_filename=$(echo "${contract}" | sed -r 's/([a-z])([A-Z])/\1_\2/g' | tr '[:upper:]' '[:lower:]') + out="contract/${go_filename}.sol.go" + if [[ $contract =~ Test$ ]]; then + out="tests/contract/${go_filename}.sol.go" + fi abigen --abi "$project_dir/contract/artifacts/${contract}.abi" \ --bin "$project_dir/contract/artifacts/${contract}.bin" \ --type "${contract}" --pkg contract \ - --out "$project_dir/contract/${contract}.go" -done - -# test contracts -for contract_test in "${contracts_test[@]}"; do - echo "===> Ethereum ABI wrapper code generator: $contract_test" - file_path=$(find "$project_dir/solidity/artifacts" -name "${contract_test}.json" -type f) - jq -c '.abi' "$file_path" >"$project_dir/contract/artifacts/${contract_test}.abi" - jq -r '.bytecode' "$file_path" >"$project_dir/contract/artifacts/${contract_test}.bin" - abigen --abi "$project_dir/contract/artifacts/${contract_test}.abi" \ - --bin "$project_dir/contract/artifacts/${contract_test}.bin" \ - --type "${contract_test}" --pkg contract \ - --out "$project_dir/tests/contract/${contract_test}.go" + --out "$project_dir/$out" done rm -rf "$project_dir/contract/artifacts" diff --git a/contract/ERC1967Proxy.go b/contract/erc1967proxy.sol.go similarity index 100% rename from contract/ERC1967Proxy.go rename to contract/erc1967proxy.sol.go diff --git a/contract/FIP20Upgradable.go b/contract/fip20upgradable.sol.go similarity index 100% rename from contract/FIP20Upgradable.go rename to contract/fip20upgradable.sol.go diff --git a/contract/IBridgeCallback.go b/contract/ibridge_callback.sol.go similarity index 100% rename from contract/IBridgeCallback.go rename to contract/ibridge_callback.sol.go diff --git a/contract/IBridgeFeeQuote.go b/contract/ibridge_fee_quote.sol.go similarity index 100% rename from contract/IBridgeFeeQuote.go rename to contract/ibridge_fee_quote.sol.go diff --git a/contract/ICrosschain.go b/contract/icrosschain.sol.go similarity index 100% rename from contract/ICrosschain.go rename to contract/icrosschain.sol.go diff --git a/contract/IError.go b/contract/ierror.sol.go similarity index 100% rename from contract/IError.go rename to contract/ierror.sol.go diff --git a/contract/IFxBridgeLogic.go b/contract/ifx_bridge_logic.sol.go similarity index 100% rename from contract/IFxBridgeLogic.go rename to contract/ifx_bridge_logic.sol.go diff --git a/contract/IStaking.go b/contract/istaking.sol.go similarity index 100% rename from contract/IStaking.go rename to contract/istaking.sol.go diff --git a/contract/WFXUpgradable.go b/contract/wfxupgradable.sol.go similarity index 100% rename from contract/WFXUpgradable.go rename to contract/wfxupgradable.sol.go diff --git a/tests/contract/CrosschainTest.go b/tests/contract/crosschain_test.sol.go similarity index 100% rename from tests/contract/CrosschainTest.go rename to tests/contract/crosschain_test.sol.go diff --git a/tests/contract/ERC721TokenTest.go b/tests/contract/erc721token_test.sol.go similarity index 100% rename from tests/contract/ERC721TokenTest.go rename to tests/contract/erc721token_test.sol.go diff --git a/tests/contract/StakingTest.go b/tests/contract/staking_test.sol.go similarity index 100% rename from tests/contract/StakingTest.go rename to tests/contract/staking_test.sol.go