diff --git a/contract/ibridge_fee_quote.sol.go b/contract/ibridge_fee_quote.sol.go index 1586e067..bd9e44f7 100644 --- a/contract/ibridge_fee_quote.sol.go +++ b/contract/ibridge_fee_quote.sol.go @@ -29,6 +29,12 @@ var ( _ = abi.ConvertType ) +// IBridgeFeeQuoteAsset is an auto generated low-level Go binding around an user-defined struct. +type IBridgeFeeQuoteAsset struct { + IsActive bool + TokenNames []string +} + // IBridgeFeeQuoteQuoteInfo is an auto generated low-level Go binding around an user-defined struct. type IBridgeFeeQuoteQuoteInfo struct { Id *big.Int @@ -54,7 +60,7 @@ type IBridgeFeeQuoteQuoteInput struct { // IBridgeFeeQuoteMetaData contains all meta data concerning the IBridgeFeeQuote contract. var IBridgeFeeQuoteMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_chainName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_tokenName\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"_oracle\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"getQuote\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"chainName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"tokenName\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expiry\",\"type\":\"uint256\"}],\"internalType\":\"structIBridgeFeeQuote.QuoteInfo\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_id\",\"type\":\"uint256\"}],\"name\":\"getQuoteById\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"chainName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"tokenName\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expiry\",\"type\":\"uint256\"}],\"internalType\":\"structIBridgeFeeQuote.QuoteInfo\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_chainName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_tokenName\",\"type\":\"string\"}],\"name\":\"getQuoteByToken\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"chainName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"tokenName\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expiry\",\"type\":\"uint256\"}],\"internalType\":\"structIBridgeFeeQuote.QuoteInfo[]\",\"name\":\"quotes\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_chainName\",\"type\":\"string\"}],\"name\":\"getQuoteList\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"chainName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"tokenName\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expiry\",\"type\":\"uint256\"}],\"internalType\":\"structIBridgeFeeQuote.QuoteInfo[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"chainName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"tokenName\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"quoteIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expiry\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"internalType\":\"structIBridgeFeeQuote.QuoteInput[]\",\"name\":\"_inputs\",\"type\":\"tuple[]\"}],\"name\":\"quote\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_chainName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_tokenName\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"_oracle\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"getQuote\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"chainName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"tokenName\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expiry\",\"type\":\"uint256\"}],\"internalType\":\"structIBridgeFeeQuote.QuoteInfo\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_id\",\"type\":\"uint256\"}],\"name\":\"getQuoteById\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"chainName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"tokenName\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expiry\",\"type\":\"uint256\"}],\"internalType\":\"structIBridgeFeeQuote.QuoteInfo\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_chainName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_tokenName\",\"type\":\"string\"}],\"name\":\"getQuoteByToken\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"chainName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"tokenName\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expiry\",\"type\":\"uint256\"}],\"internalType\":\"structIBridgeFeeQuote.QuoteInfo[]\",\"name\":\"quotes\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_chainName\",\"type\":\"string\"}],\"name\":\"getQuoteList\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"chainName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"tokenName\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expiry\",\"type\":\"uint256\"}],\"internalType\":\"structIBridgeFeeQuote.QuoteInfo[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"chainName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"tokenName\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"quoteIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expiry\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"internalType\":\"structIBridgeFeeQuote.QuoteInput[]\",\"name\":\"_inputs\",\"type\":\"tuple[]\"}],\"name\":\"quote\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_chainName\",\"type\":\"string\"}],\"name\":\"supportAssets\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isActive\",\"type\":\"bool\"},{\"internalType\":\"string[]\",\"name\":\"tokenNames\",\"type\":\"string[]\"}],\"internalType\":\"structIBridgeFeeQuote.Asset\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"supportChainNames\",\"outputs\":[{\"internalType\":\"string[]\",\"name\":\"\",\"type\":\"string[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", } // IBridgeFeeQuoteABI is the input ABI used to generate the binding from. @@ -327,6 +333,68 @@ func (_IBridgeFeeQuote *IBridgeFeeQuoteCallerSession) GetQuoteList(_chainName st return _IBridgeFeeQuote.Contract.GetQuoteList(&_IBridgeFeeQuote.CallOpts, _chainName) } +// SupportAssets is a free data retrieval call binding the contract method 0x1b826a1b. +// +// Solidity: function supportAssets(string _chainName) view returns((bool,string[])) +func (_IBridgeFeeQuote *IBridgeFeeQuoteCaller) SupportAssets(opts *bind.CallOpts, _chainName string) (IBridgeFeeQuoteAsset, error) { + var out []interface{} + err := _IBridgeFeeQuote.contract.Call(opts, &out, "supportAssets", _chainName) + + if err != nil { + return *new(IBridgeFeeQuoteAsset), err + } + + out0 := *abi.ConvertType(out[0], new(IBridgeFeeQuoteAsset)).(*IBridgeFeeQuoteAsset) + + return out0, err + +} + +// SupportAssets is a free data retrieval call binding the contract method 0x1b826a1b. +// +// Solidity: function supportAssets(string _chainName) view returns((bool,string[])) +func (_IBridgeFeeQuote *IBridgeFeeQuoteSession) SupportAssets(_chainName string) (IBridgeFeeQuoteAsset, error) { + return _IBridgeFeeQuote.Contract.SupportAssets(&_IBridgeFeeQuote.CallOpts, _chainName) +} + +// SupportAssets is a free data retrieval call binding the contract method 0x1b826a1b. +// +// Solidity: function supportAssets(string _chainName) view returns((bool,string[])) +func (_IBridgeFeeQuote *IBridgeFeeQuoteCallerSession) SupportAssets(_chainName string) (IBridgeFeeQuoteAsset, error) { + return _IBridgeFeeQuote.Contract.SupportAssets(&_IBridgeFeeQuote.CallOpts, _chainName) +} + +// SupportChainNames is a free data retrieval call binding the contract method 0x0a1d133c. +// +// Solidity: function supportChainNames() view returns(string[]) +func (_IBridgeFeeQuote *IBridgeFeeQuoteCaller) SupportChainNames(opts *bind.CallOpts) ([]string, error) { + var out []interface{} + err := _IBridgeFeeQuote.contract.Call(opts, &out, "supportChainNames") + + if err != nil { + return *new([]string), err + } + + out0 := *abi.ConvertType(out[0], new([]string)).(*[]string) + + return out0, err + +} + +// SupportChainNames is a free data retrieval call binding the contract method 0x0a1d133c. +// +// Solidity: function supportChainNames() view returns(string[]) +func (_IBridgeFeeQuote *IBridgeFeeQuoteSession) SupportChainNames() ([]string, error) { + return _IBridgeFeeQuote.Contract.SupportChainNames(&_IBridgeFeeQuote.CallOpts) +} + +// SupportChainNames is a free data retrieval call binding the contract method 0x0a1d133c. +// +// Solidity: function supportChainNames() view returns(string[]) +func (_IBridgeFeeQuote *IBridgeFeeQuoteCallerSession) SupportChainNames() ([]string, error) { + return _IBridgeFeeQuote.Contract.SupportChainNames(&_IBridgeFeeQuote.CallOpts) +} + // Quote is a paid mutator transaction binding the contract method 0xc994e71a. // // Solidity: function quote((string,string,address,uint256,uint256,uint256,uint256,bytes)[] _inputs) returns(bool) diff --git a/solidity/contracts/bridge/BridgeFeeQuote.sol b/solidity/contracts/bridge/BridgeFeeQuote.sol index 5be5b49f..bd888326 100644 --- a/solidity/contracts/bridge/BridgeFeeQuote.sol +++ b/solidity/contracts/bridge/BridgeFeeQuote.sol @@ -32,11 +32,6 @@ contract BridgeFeeQuote is using ECDSAUpgradeable for bytes32; using StringsUpgradeable for string; - struct Asset { - bool isActive; - string[] tokenNames; - } - struct Quote { uint256 id; uint256 fee; @@ -275,6 +270,16 @@ contract BridgeFeeQuote is }); } + function supportChainNames() external view returns (string[] memory) { + return chainNames; + } + + function supportAssets( + string memory _chainName + ) external view returns (Asset memory) { + return assets[_chainName]; + } + function verifyInput(QuoteInput memory _input) private { if (!assets[_input.chainName].isActive) { revert ChainNameInvalid(); diff --git a/solidity/contracts/bridge/IBridgeFee.sol b/solidity/contracts/bridge/IBridgeFee.sol index 35d3c4d1..a99cabf9 100644 --- a/solidity/contracts/bridge/IBridgeFee.sol +++ b/solidity/contracts/bridge/IBridgeFee.sol @@ -3,6 +3,11 @@ pragma solidity ^0.8.0; interface IBridgeFeeQuote { + struct Asset { + bool isActive; + string[] tokenNames; + } + struct QuoteInput { string chainName; string tokenName; @@ -43,6 +48,12 @@ interface IBridgeFeeQuote { address _oracle, uint256 _index ) external view returns (QuoteInfo memory); + + function supportChainNames() external view returns (string[] memory); + + function supportAssets( + string memory _chainName + ) external view returns (Asset memory); } interface IBridgeFeeOracle {