From b23885e57e9b3b32d0f971981211da63185017fe Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Tue, 26 Nov 2024 16:39:34 +0200 Subject: [PATCH] off-chain part --- contracts/src/Gateway.sol | 8 + contracts/src/v2/Calls.sol | 4 + contracts/src/v2/IGateway.sol | 2 + relayer/contracts/gateway.go | 1873 +++--------------------------- relayer/generate.go | 2 +- relayer/relays/execution/main.go | 145 ++- 6 files changed, 272 insertions(+), 1762 deletions(-) diff --git a/contracts/src/Gateway.sol b/contracts/src/Gateway.sol index 7d18be0e96..ec6198bf57 100644 --- a/contracts/src/Gateway.sol +++ b/contracts/src/Gateway.sol @@ -280,6 +280,14 @@ contract Gateway is IGatewayBase, IGatewayV1, IGatewayV2, IInitializable, IUpgra return Functions.ensureAgent(agentID); } + function outboundNonce() + external + view + returns (uint64) + { + return CallsV2.outboundNonce(); + } + function pricingParameters() external view returns (UD60x18, uint128) { return CallsV1.pricingParameters(); } diff --git a/contracts/src/v2/Calls.sol b/contracts/src/v2/Calls.sol index 5f987a2a93..ce19d32ac6 100644 --- a/contracts/src/v2/Calls.sol +++ b/contracts/src/v2/Calls.sol @@ -227,4 +227,8 @@ library CallsV2 { ); } } + + function outboundNonce() external view returns (uint64) { + return CoreStorage.layout().outboundNonce; + } } diff --git a/contracts/src/v2/IGateway.sol b/contracts/src/v2/IGateway.sol index 78e76f9785..879e51e533 100644 --- a/contracts/src/v2/IGateway.sol +++ b/contracts/src/v2/IGateway.sol @@ -16,6 +16,8 @@ interface IGatewayV2 { function agentOf(bytes32 agentID) external view returns (address); + function outboundNonce() external view returns (uint64); + /** * Events */ diff --git a/relayer/contracts/gateway.go b/relayer/contracts/gateway.go index ff6723fc6c..f53896d88d 100644 --- a/relayer/contracts/gateway.go +++ b/relayer/contracts/gateway.go @@ -29,22 +29,18 @@ var ( _ = abi.ConvertType ) -// InboundMessage is an auto generated low-level Go binding around an user-defined struct. -type InboundMessage struct { - ChannelID [32]byte - Nonce uint64 - Command uint8 - Params []byte - MaxDispatchGas uint64 - MaxFeePerGas *big.Int - Reward *big.Int - Id [32]byte +// Command is an auto generated low-level Go binding around an user-defined struct. +type Command struct { + Kind uint8 + Gas uint64 + Payload []byte } -// MultiAddress is an auto generated low-level Go binding around an user-defined struct. -type MultiAddress struct { - Kind uint8 - Data []byte +// InboundMessage is an auto generated low-level Go binding around an user-defined struct. +type InboundMessage struct { + Origin [32]byte + Nonce uint64 + Commands []Command } // VerificationDigestItem is an auto generated low-level Go binding around an user-defined struct. @@ -91,7 +87,7 @@ type VerificationProof struct { // GatewayMetaData contains all meta data concerning the Gateway contract. var GatewayMetaData = &bind.MetaData{ - ABI: "[{\"type\":\"function\",\"name\":\"agentOf\",\"inputs\":[{\"name\":\"agentID\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"channelNoncesOf\",\"inputs\":[{\"name\":\"channelID\",\"type\":\"bytes32\",\"internalType\":\"ChannelID\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"channelOperatingModeOf\",\"inputs\":[{\"name\":\"channelID\",\"type\":\"bytes32\",\"internalType\":\"ChannelID\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint8\",\"internalType\":\"enumOperatingMode\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"implementation\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"isTokenRegistered\",\"inputs\":[{\"name\":\"token\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"operatingMode\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint8\",\"internalType\":\"enumOperatingMode\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"pricingParameters\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"UD60x18\"},{\"name\":\"\",\"type\":\"uint128\",\"internalType\":\"uint128\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"quoteRegisterTokenFee\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"quoteSendTokenFee\",\"inputs\":[{\"name\":\"token\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"destinationChain\",\"type\":\"uint32\",\"internalType\":\"ParaID\"},{\"name\":\"destinationFee\",\"type\":\"uint128\",\"internalType\":\"uint128\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"registerToken\",\"inputs\":[{\"name\":\"token\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"sendToken\",\"inputs\":[{\"name\":\"token\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"destinationChain\",\"type\":\"uint32\",\"internalType\":\"ParaID\"},{\"name\":\"destinationAddress\",\"type\":\"tuple\",\"internalType\":\"structMultiAddress\",\"components\":[{\"name\":\"kind\",\"type\":\"uint8\",\"internalType\":\"enumKind\"},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"name\":\"destinationFee\",\"type\":\"uint128\",\"internalType\":\"uint128\"},{\"name\":\"amount\",\"type\":\"uint128\",\"internalType\":\"uint128\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"submitV1\",\"inputs\":[{\"name\":\"message\",\"type\":\"tuple\",\"internalType\":\"structInboundMessage\",\"components\":[{\"name\":\"channelID\",\"type\":\"bytes32\",\"internalType\":\"ChannelID\"},{\"name\":\"nonce\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"command\",\"type\":\"uint8\",\"internalType\":\"enumCommand\"},{\"name\":\"params\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"maxDispatchGas\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"maxFeePerGas\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"reward\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"id\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"name\":\"leafProof\",\"type\":\"bytes32[]\",\"internalType\":\"bytes32[]\"},{\"name\":\"headerProof\",\"type\":\"tuple\",\"internalType\":\"structVerification.Proof\",\"components\":[{\"name\":\"header\",\"type\":\"tuple\",\"internalType\":\"structVerification.ParachainHeader\",\"components\":[{\"name\":\"parentHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"number\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"stateRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"extrinsicsRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"digestItems\",\"type\":\"tuple[]\",\"internalType\":\"structVerification.DigestItem[]\",\"components\":[{\"name\":\"kind\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"consensusEngineID\",\"type\":\"bytes4\",\"internalType\":\"bytes4\"},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}]},{\"name\":\"headProof\",\"type\":\"tuple\",\"internalType\":\"structVerification.HeadProof\",\"components\":[{\"name\":\"pos\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"width\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"proof\",\"type\":\"bytes32[]\",\"internalType\":\"bytes32[]\"}]},{\"name\":\"leafPartial\",\"type\":\"tuple\",\"internalType\":\"structVerification.MMRLeafPartial\",\"components\":[{\"name\":\"version\",\"type\":\"uint8\",\"internalType\":\"uint8\"},{\"name\":\"parentNumber\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"parentHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"nextAuthoritySetID\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"nextAuthoritySetLen\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"nextAuthoritySetRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"name\":\"leafProof\",\"type\":\"bytes32[]\",\"internalType\":\"bytes32[]\"},{\"name\":\"leafProofOrder\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"event\",\"name\":\"AgentCreated\",\"inputs\":[{\"name\":\"agentID\",\"type\":\"bytes32\",\"indexed\":false,\"internalType\":\"bytes32\"},{\"name\":\"agent\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"AgentFundsWithdrawn\",\"inputs\":[{\"name\":\"agentID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"},{\"name\":\"recipient\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"ChannelCreated\",\"inputs\":[{\"name\":\"channelID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"ChannelID\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"ChannelUpdated\",\"inputs\":[{\"name\":\"channelID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"ChannelID\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"ForeignTokenRegistered\",\"inputs\":[{\"name\":\"tokenID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"},{\"name\":\"token\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"InboundMessageDispatched\",\"inputs\":[{\"name\":\"channelID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"ChannelID\"},{\"name\":\"nonce\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"},{\"name\":\"messageID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"},{\"name\":\"success\",\"type\":\"bool\",\"indexed\":false,\"internalType\":\"bool\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OperatingModeChanged\",\"inputs\":[{\"name\":\"mode\",\"type\":\"uint8\",\"indexed\":false,\"internalType\":\"enumOperatingMode\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OutboundMessageAccepted\",\"inputs\":[{\"name\":\"channelID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"ChannelID\"},{\"name\":\"nonce\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"},{\"name\":\"messageID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"},{\"name\":\"payload\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"PricingParametersChanged\",\"inputs\":[],\"anonymous\":false},{\"type\":\"event\",\"name\":\"TokenRegistrationSent\",\"inputs\":[{\"name\":\"token\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"TokenSent\",\"inputs\":[{\"name\":\"token\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"sender\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"destinationChain\",\"type\":\"uint32\",\"indexed\":true,\"internalType\":\"ParaID\"},{\"name\":\"destinationAddress\",\"type\":\"tuple\",\"indexed\":false,\"internalType\":\"structMultiAddress\",\"components\":[{\"name\":\"kind\",\"type\":\"uint8\",\"internalType\":\"enumKind\"},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"name\":\"amount\",\"type\":\"uint128\",\"indexed\":false,\"internalType\":\"uint128\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"TokenTransferFeesChanged\",\"inputs\":[],\"anonymous\":false}]", + ABI: "[{\"type\":\"function\",\"name\":\"agentOf\",\"inputs\":[{\"name\":\"agentID\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"isTokenRegistered\",\"inputs\":[{\"name\":\"token\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"operatingMode\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint8\",\"internalType\":\"enumOperatingMode\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"outboundNonce\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"v2_isDispatched\",\"inputs\":[{\"name\":\"nonce\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"v2_registerToken\",\"inputs\":[{\"name\":\"token\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"xcmFeeAHP\",\"type\":\"uint128\",\"internalType\":\"uint128\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"v2_registerTokenOnKusama\",\"inputs\":[{\"name\":\"token\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"xcmFeeAHP\",\"type\":\"uint128\",\"internalType\":\"uint128\"},{\"name\":\"xcmFeeAHK\",\"type\":\"uint128\",\"internalType\":\"uint128\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"v2_sendMessage\",\"inputs\":[{\"name\":\"xcm\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"assets\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"},{\"name\":\"claimer\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"v2_submit\",\"inputs\":[{\"name\":\"message\",\"type\":\"tuple\",\"internalType\":\"structInboundMessage\",\"components\":[{\"name\":\"origin\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"nonce\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"commands\",\"type\":\"tuple[]\",\"internalType\":\"structCommand[]\",\"components\":[{\"name\":\"kind\",\"type\":\"uint8\",\"internalType\":\"uint8\"},{\"name\":\"gas\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"payload\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}]},{\"name\":\"leafProof\",\"type\":\"bytes32[]\",\"internalType\":\"bytes32[]\"},{\"name\":\"headerProof\",\"type\":\"tuple\",\"internalType\":\"structVerification.Proof\",\"components\":[{\"name\":\"header\",\"type\":\"tuple\",\"internalType\":\"structVerification.ParachainHeader\",\"components\":[{\"name\":\"parentHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"number\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"stateRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"extrinsicsRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"digestItems\",\"type\":\"tuple[]\",\"internalType\":\"structVerification.DigestItem[]\",\"components\":[{\"name\":\"kind\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"consensusEngineID\",\"type\":\"bytes4\",\"internalType\":\"bytes4\"},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}]},{\"name\":\"headProof\",\"type\":\"tuple\",\"internalType\":\"structVerification.HeadProof\",\"components\":[{\"name\":\"pos\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"width\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"proof\",\"type\":\"bytes32[]\",\"internalType\":\"bytes32[]\"}]},{\"name\":\"leafPartial\",\"type\":\"tuple\",\"internalType\":\"structVerification.MMRLeafPartial\",\"components\":[{\"name\":\"version\",\"type\":\"uint8\",\"internalType\":\"uint8\"},{\"name\":\"parentNumber\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"parentHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"nextAuthoritySetID\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"nextAuthoritySetLen\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"nextAuthoritySetRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"name\":\"leafProof\",\"type\":\"bytes32[]\",\"internalType\":\"bytes32[]\"},{\"name\":\"leafProofOrder\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"name\":\"rewardAddress\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"event\",\"name\":\"InboundMessageDispatched\",\"inputs\":[{\"name\":\"nonce\",\"type\":\"uint64\",\"indexed\":true,\"internalType\":\"uint64\"},{\"name\":\"success\",\"type\":\"bool\",\"indexed\":false,\"internalType\":\"bool\"},{\"name\":\"rewardAddress\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OutboundMessageAccepted\",\"inputs\":[{\"name\":\"nonce\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"},{\"name\":\"reward\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"payload\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"}],\"anonymous\":false},{\"type\":\"error\",\"name\":\"InvalidAsset\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidEtherValue\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidFee\",\"inputs\":[]}]", } // GatewayABI is the input ABI used to generate the binding from. @@ -271,100 +267,6 @@ func (_Gateway *GatewayCallerSession) AgentOf(agentID [32]byte) (common.Address, return _Gateway.Contract.AgentOf(&_Gateway.CallOpts, agentID) } -// ChannelNoncesOf is a free data retrieval call binding the contract method 0x2a6c3229. -// -// Solidity: function channelNoncesOf(bytes32 channelID) view returns(uint64, uint64) -func (_Gateway *GatewayCaller) ChannelNoncesOf(opts *bind.CallOpts, channelID [32]byte) (uint64, uint64, error) { - var out []interface{} - err := _Gateway.contract.Call(opts, &out, "channelNoncesOf", channelID) - - if err != nil { - return *new(uint64), *new(uint64), err - } - - out0 := *abi.ConvertType(out[0], new(uint64)).(*uint64) - out1 := *abi.ConvertType(out[1], new(uint64)).(*uint64) - - return out0, out1, err - -} - -// ChannelNoncesOf is a free data retrieval call binding the contract method 0x2a6c3229. -// -// Solidity: function channelNoncesOf(bytes32 channelID) view returns(uint64, uint64) -func (_Gateway *GatewaySession) ChannelNoncesOf(channelID [32]byte) (uint64, uint64, error) { - return _Gateway.Contract.ChannelNoncesOf(&_Gateway.CallOpts, channelID) -} - -// ChannelNoncesOf is a free data retrieval call binding the contract method 0x2a6c3229. -// -// Solidity: function channelNoncesOf(bytes32 channelID) view returns(uint64, uint64) -func (_Gateway *GatewayCallerSession) ChannelNoncesOf(channelID [32]byte) (uint64, uint64, error) { - return _Gateway.Contract.ChannelNoncesOf(&_Gateway.CallOpts, channelID) -} - -// ChannelOperatingModeOf is a free data retrieval call binding the contract method 0x0705f465. -// -// Solidity: function channelOperatingModeOf(bytes32 channelID) view returns(uint8) -func (_Gateway *GatewayCaller) ChannelOperatingModeOf(opts *bind.CallOpts, channelID [32]byte) (uint8, error) { - var out []interface{} - err := _Gateway.contract.Call(opts, &out, "channelOperatingModeOf", channelID) - - if err != nil { - return *new(uint8), err - } - - out0 := *abi.ConvertType(out[0], new(uint8)).(*uint8) - - return out0, err - -} - -// ChannelOperatingModeOf is a free data retrieval call binding the contract method 0x0705f465. -// -// Solidity: function channelOperatingModeOf(bytes32 channelID) view returns(uint8) -func (_Gateway *GatewaySession) ChannelOperatingModeOf(channelID [32]byte) (uint8, error) { - return _Gateway.Contract.ChannelOperatingModeOf(&_Gateway.CallOpts, channelID) -} - -// ChannelOperatingModeOf is a free data retrieval call binding the contract method 0x0705f465. -// -// Solidity: function channelOperatingModeOf(bytes32 channelID) view returns(uint8) -func (_Gateway *GatewayCallerSession) ChannelOperatingModeOf(channelID [32]byte) (uint8, error) { - return _Gateway.Contract.ChannelOperatingModeOf(&_Gateway.CallOpts, channelID) -} - -// Implementation is a free data retrieval call binding the contract method 0x5c60da1b. -// -// Solidity: function implementation() view returns(address) -func (_Gateway *GatewayCaller) Implementation(opts *bind.CallOpts) (common.Address, error) { - var out []interface{} - err := _Gateway.contract.Call(opts, &out, "implementation") - - if err != nil { - return *new(common.Address), err - } - - out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - - return out0, err - -} - -// Implementation is a free data retrieval call binding the contract method 0x5c60da1b. -// -// Solidity: function implementation() view returns(address) -func (_Gateway *GatewaySession) Implementation() (common.Address, error) { - return _Gateway.Contract.Implementation(&_Gateway.CallOpts) -} - -// Implementation is a free data retrieval call binding the contract method 0x5c60da1b. -// -// Solidity: function implementation() view returns(address) -func (_Gateway *GatewayCallerSession) Implementation() (common.Address, error) { - return _Gateway.Contract.Implementation(&_Gateway.CallOpts) -} - // IsTokenRegistered is a free data retrieval call binding the contract method 0x26aa101f. // // Solidity: function isTokenRegistered(address token) view returns(bool) @@ -427,301 +329,155 @@ func (_Gateway *GatewayCallerSession) OperatingMode() (uint8, error) { return _Gateway.Contract.OperatingMode(&_Gateway.CallOpts) } -// PricingParameters is a free data retrieval call binding the contract method 0x0b617646. -// -// Solidity: function pricingParameters() view returns(uint256, uint128) -func (_Gateway *GatewayCaller) PricingParameters(opts *bind.CallOpts) (*big.Int, *big.Int, error) { - var out []interface{} - err := _Gateway.contract.Call(opts, &out, "pricingParameters") - - if err != nil { - return *new(*big.Int), *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - out1 := *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) - - return out0, out1, err - -} - -// PricingParameters is a free data retrieval call binding the contract method 0x0b617646. -// -// Solidity: function pricingParameters() view returns(uint256, uint128) -func (_Gateway *GatewaySession) PricingParameters() (*big.Int, *big.Int, error) { - return _Gateway.Contract.PricingParameters(&_Gateway.CallOpts) -} - -// PricingParameters is a free data retrieval call binding the contract method 0x0b617646. +// OutboundNonce is a free data retrieval call binding the contract method 0xfd10ebe5. // -// Solidity: function pricingParameters() view returns(uint256, uint128) -func (_Gateway *GatewayCallerSession) PricingParameters() (*big.Int, *big.Int, error) { - return _Gateway.Contract.PricingParameters(&_Gateway.CallOpts) -} - -// QuoteRegisterTokenFee is a free data retrieval call binding the contract method 0x805ce31d. -// -// Solidity: function quoteRegisterTokenFee() view returns(uint256) -func (_Gateway *GatewayCaller) QuoteRegisterTokenFee(opts *bind.CallOpts) (*big.Int, error) { +// Solidity: function outboundNonce() view returns(uint64) +func (_Gateway *GatewayCaller) OutboundNonce(opts *bind.CallOpts) (uint64, error) { var out []interface{} - err := _Gateway.contract.Call(opts, &out, "quoteRegisterTokenFee") + err := _Gateway.contract.Call(opts, &out, "outboundNonce") if err != nil { - return *new(*big.Int), err + return *new(uint64), err } - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + out0 := *abi.ConvertType(out[0], new(uint64)).(*uint64) return out0, err } -// QuoteRegisterTokenFee is a free data retrieval call binding the contract method 0x805ce31d. +// OutboundNonce is a free data retrieval call binding the contract method 0xfd10ebe5. // -// Solidity: function quoteRegisterTokenFee() view returns(uint256) -func (_Gateway *GatewaySession) QuoteRegisterTokenFee() (*big.Int, error) { - return _Gateway.Contract.QuoteRegisterTokenFee(&_Gateway.CallOpts) +// Solidity: function outboundNonce() view returns(uint64) +func (_Gateway *GatewaySession) OutboundNonce() (uint64, error) { + return _Gateway.Contract.OutboundNonce(&_Gateway.CallOpts) } -// QuoteRegisterTokenFee is a free data retrieval call binding the contract method 0x805ce31d. +// OutboundNonce is a free data retrieval call binding the contract method 0xfd10ebe5. // -// Solidity: function quoteRegisterTokenFee() view returns(uint256) -func (_Gateway *GatewayCallerSession) QuoteRegisterTokenFee() (*big.Int, error) { - return _Gateway.Contract.QuoteRegisterTokenFee(&_Gateway.CallOpts) +// Solidity: function outboundNonce() view returns(uint64) +func (_Gateway *GatewayCallerSession) OutboundNonce() (uint64, error) { + return _Gateway.Contract.OutboundNonce(&_Gateway.CallOpts) } -// QuoteSendTokenFee is a free data retrieval call binding the contract method 0x928bc49d. +// V2IsDispatched is a free data retrieval call binding the contract method 0xc66414c5. // -// Solidity: function quoteSendTokenFee(address token, uint32 destinationChain, uint128 destinationFee) view returns(uint256) -func (_Gateway *GatewayCaller) QuoteSendTokenFee(opts *bind.CallOpts, token common.Address, destinationChain uint32, destinationFee *big.Int) (*big.Int, error) { +// Solidity: function v2_isDispatched(uint64 nonce) view returns(bool) +func (_Gateway *GatewayCaller) V2IsDispatched(opts *bind.CallOpts, nonce uint64) (bool, error) { var out []interface{} - err := _Gateway.contract.Call(opts, &out, "quoteSendTokenFee", token, destinationChain, destinationFee) + err := _Gateway.contract.Call(opts, &out, "v2_isDispatched", nonce) if err != nil { - return *new(*big.Int), err + return *new(bool), err } - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) return out0, err } -// QuoteSendTokenFee is a free data retrieval call binding the contract method 0x928bc49d. +// V2IsDispatched is a free data retrieval call binding the contract method 0xc66414c5. // -// Solidity: function quoteSendTokenFee(address token, uint32 destinationChain, uint128 destinationFee) view returns(uint256) -func (_Gateway *GatewaySession) QuoteSendTokenFee(token common.Address, destinationChain uint32, destinationFee *big.Int) (*big.Int, error) { - return _Gateway.Contract.QuoteSendTokenFee(&_Gateway.CallOpts, token, destinationChain, destinationFee) +// Solidity: function v2_isDispatched(uint64 nonce) view returns(bool) +func (_Gateway *GatewaySession) V2IsDispatched(nonce uint64) (bool, error) { + return _Gateway.Contract.V2IsDispatched(&_Gateway.CallOpts, nonce) } -// QuoteSendTokenFee is a free data retrieval call binding the contract method 0x928bc49d. +// V2IsDispatched is a free data retrieval call binding the contract method 0xc66414c5. // -// Solidity: function quoteSendTokenFee(address token, uint32 destinationChain, uint128 destinationFee) view returns(uint256) -func (_Gateway *GatewayCallerSession) QuoteSendTokenFee(token common.Address, destinationChain uint32, destinationFee *big.Int) (*big.Int, error) { - return _Gateway.Contract.QuoteSendTokenFee(&_Gateway.CallOpts, token, destinationChain, destinationFee) +// Solidity: function v2_isDispatched(uint64 nonce) view returns(bool) +func (_Gateway *GatewayCallerSession) V2IsDispatched(nonce uint64) (bool, error) { + return _Gateway.Contract.V2IsDispatched(&_Gateway.CallOpts, nonce) } -// RegisterToken is a paid mutator transaction binding the contract method 0x09824a80. +// V2RegisterToken is a paid mutator transaction binding the contract method 0xd0b8c486. // -// Solidity: function registerToken(address token) payable returns() -func (_Gateway *GatewayTransactor) RegisterToken(opts *bind.TransactOpts, token common.Address) (*types.Transaction, error) { - return _Gateway.contract.Transact(opts, "registerToken", token) +// Solidity: function v2_registerToken(address token, uint128 xcmFeeAHP) payable returns() +func (_Gateway *GatewayTransactor) V2RegisterToken(opts *bind.TransactOpts, token common.Address, xcmFeeAHP *big.Int) (*types.Transaction, error) { + return _Gateway.contract.Transact(opts, "v2_registerToken", token, xcmFeeAHP) } -// RegisterToken is a paid mutator transaction binding the contract method 0x09824a80. +// V2RegisterToken is a paid mutator transaction binding the contract method 0xd0b8c486. // -// Solidity: function registerToken(address token) payable returns() -func (_Gateway *GatewaySession) RegisterToken(token common.Address) (*types.Transaction, error) { - return _Gateway.Contract.RegisterToken(&_Gateway.TransactOpts, token) +// Solidity: function v2_registerToken(address token, uint128 xcmFeeAHP) payable returns() +func (_Gateway *GatewaySession) V2RegisterToken(token common.Address, xcmFeeAHP *big.Int) (*types.Transaction, error) { + return _Gateway.Contract.V2RegisterToken(&_Gateway.TransactOpts, token, xcmFeeAHP) } -// RegisterToken is a paid mutator transaction binding the contract method 0x09824a80. +// V2RegisterToken is a paid mutator transaction binding the contract method 0xd0b8c486. // -// Solidity: function registerToken(address token) payable returns() -func (_Gateway *GatewayTransactorSession) RegisterToken(token common.Address) (*types.Transaction, error) { - return _Gateway.Contract.RegisterToken(&_Gateway.TransactOpts, token) +// Solidity: function v2_registerToken(address token, uint128 xcmFeeAHP) payable returns() +func (_Gateway *GatewayTransactorSession) V2RegisterToken(token common.Address, xcmFeeAHP *big.Int) (*types.Transaction, error) { + return _Gateway.Contract.V2RegisterToken(&_Gateway.TransactOpts, token, xcmFeeAHP) } -// SendToken is a paid mutator transaction binding the contract method 0x52054834. +// V2RegisterTokenOnKusama is a paid mutator transaction binding the contract method 0x49c481ba. // -// Solidity: function sendToken(address token, uint32 destinationChain, (uint8,bytes) destinationAddress, uint128 destinationFee, uint128 amount) payable returns() -func (_Gateway *GatewayTransactor) SendToken(opts *bind.TransactOpts, token common.Address, destinationChain uint32, destinationAddress MultiAddress, destinationFee *big.Int, amount *big.Int) (*types.Transaction, error) { - return _Gateway.contract.Transact(opts, "sendToken", token, destinationChain, destinationAddress, destinationFee, amount) +// Solidity: function v2_registerTokenOnKusama(address token, uint128 xcmFeeAHP, uint128 xcmFeeAHK) payable returns() +func (_Gateway *GatewayTransactor) V2RegisterTokenOnKusama(opts *bind.TransactOpts, token common.Address, xcmFeeAHP *big.Int, xcmFeeAHK *big.Int) (*types.Transaction, error) { + return _Gateway.contract.Transact(opts, "v2_registerTokenOnKusama", token, xcmFeeAHP, xcmFeeAHK) } -// SendToken is a paid mutator transaction binding the contract method 0x52054834. +// V2RegisterTokenOnKusama is a paid mutator transaction binding the contract method 0x49c481ba. // -// Solidity: function sendToken(address token, uint32 destinationChain, (uint8,bytes) destinationAddress, uint128 destinationFee, uint128 amount) payable returns() -func (_Gateway *GatewaySession) SendToken(token common.Address, destinationChain uint32, destinationAddress MultiAddress, destinationFee *big.Int, amount *big.Int) (*types.Transaction, error) { - return _Gateway.Contract.SendToken(&_Gateway.TransactOpts, token, destinationChain, destinationAddress, destinationFee, amount) +// Solidity: function v2_registerTokenOnKusama(address token, uint128 xcmFeeAHP, uint128 xcmFeeAHK) payable returns() +func (_Gateway *GatewaySession) V2RegisterTokenOnKusama(token common.Address, xcmFeeAHP *big.Int, xcmFeeAHK *big.Int) (*types.Transaction, error) { + return _Gateway.Contract.V2RegisterTokenOnKusama(&_Gateway.TransactOpts, token, xcmFeeAHP, xcmFeeAHK) } -// SendToken is a paid mutator transaction binding the contract method 0x52054834. +// V2RegisterTokenOnKusama is a paid mutator transaction binding the contract method 0x49c481ba. // -// Solidity: function sendToken(address token, uint32 destinationChain, (uint8,bytes) destinationAddress, uint128 destinationFee, uint128 amount) payable returns() -func (_Gateway *GatewayTransactorSession) SendToken(token common.Address, destinationChain uint32, destinationAddress MultiAddress, destinationFee *big.Int, amount *big.Int) (*types.Transaction, error) { - return _Gateway.Contract.SendToken(&_Gateway.TransactOpts, token, destinationChain, destinationAddress, destinationFee, amount) +// Solidity: function v2_registerTokenOnKusama(address token, uint128 xcmFeeAHP, uint128 xcmFeeAHK) payable returns() +func (_Gateway *GatewayTransactorSession) V2RegisterTokenOnKusama(token common.Address, xcmFeeAHP *big.Int, xcmFeeAHK *big.Int) (*types.Transaction, error) { + return _Gateway.Contract.V2RegisterTokenOnKusama(&_Gateway.TransactOpts, token, xcmFeeAHP, xcmFeeAHK) } -// SubmitV1 is a paid mutator transaction binding the contract method 0xdf4ed829. +// V2SendMessage is a paid mutator transaction binding the contract method 0xb7c02d39. // -// Solidity: function submitV1((bytes32,uint64,uint8,bytes,uint64,uint256,uint256,bytes32) message, bytes32[] leafProof, ((bytes32,uint256,bytes32,bytes32,(uint256,bytes4,bytes)[]),(uint256,uint256,bytes32[]),(uint8,uint32,bytes32,uint64,uint32,bytes32),bytes32[],uint256) headerProof) returns() -func (_Gateway *GatewayTransactor) SubmitV1(opts *bind.TransactOpts, message InboundMessage, leafProof [][32]byte, headerProof VerificationProof) (*types.Transaction, error) { - return _Gateway.contract.Transact(opts, "submitV1", message, leafProof, headerProof) +// Solidity: function v2_sendMessage(bytes xcm, bytes[] assets, bytes claimer) payable returns() +func (_Gateway *GatewayTransactor) V2SendMessage(opts *bind.TransactOpts, xcm []byte, assets [][]byte, claimer []byte) (*types.Transaction, error) { + return _Gateway.contract.Transact(opts, "v2_sendMessage", xcm, assets, claimer) } -// SubmitV1 is a paid mutator transaction binding the contract method 0xdf4ed829. +// V2SendMessage is a paid mutator transaction binding the contract method 0xb7c02d39. // -// Solidity: function submitV1((bytes32,uint64,uint8,bytes,uint64,uint256,uint256,bytes32) message, bytes32[] leafProof, ((bytes32,uint256,bytes32,bytes32,(uint256,bytes4,bytes)[]),(uint256,uint256,bytes32[]),(uint8,uint32,bytes32,uint64,uint32,bytes32),bytes32[],uint256) headerProof) returns() -func (_Gateway *GatewaySession) SubmitV1(message InboundMessage, leafProof [][32]byte, headerProof VerificationProof) (*types.Transaction, error) { - return _Gateway.Contract.SubmitV1(&_Gateway.TransactOpts, message, leafProof, headerProof) +// Solidity: function v2_sendMessage(bytes xcm, bytes[] assets, bytes claimer) payable returns() +func (_Gateway *GatewaySession) V2SendMessage(xcm []byte, assets [][]byte, claimer []byte) (*types.Transaction, error) { + return _Gateway.Contract.V2SendMessage(&_Gateway.TransactOpts, xcm, assets, claimer) } -// SubmitV1 is a paid mutator transaction binding the contract method 0xdf4ed829. +// V2SendMessage is a paid mutator transaction binding the contract method 0xb7c02d39. // -// Solidity: function submitV1((bytes32,uint64,uint8,bytes,uint64,uint256,uint256,bytes32) message, bytes32[] leafProof, ((bytes32,uint256,bytes32,bytes32,(uint256,bytes4,bytes)[]),(uint256,uint256,bytes32[]),(uint8,uint32,bytes32,uint64,uint32,bytes32),bytes32[],uint256) headerProof) returns() -func (_Gateway *GatewayTransactorSession) SubmitV1(message InboundMessage, leafProof [][32]byte, headerProof VerificationProof) (*types.Transaction, error) { - return _Gateway.Contract.SubmitV1(&_Gateway.TransactOpts, message, leafProof, headerProof) -} - -// GatewayAgentCreatedIterator is returned from FilterAgentCreated and is used to iterate over the raw logs and unpacked data for AgentCreated events raised by the Gateway contract. -type GatewayAgentCreatedIterator struct { - Event *GatewayAgentCreated // 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 *GatewayAgentCreatedIterator) 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(GatewayAgentCreated) - 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(GatewayAgentCreated) - 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 *GatewayAgentCreatedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *GatewayAgentCreatedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// GatewayAgentCreated represents a AgentCreated event raised by the Gateway contract. -type GatewayAgentCreated struct { - AgentID [32]byte - Agent common.Address - Raw types.Log // Blockchain specific contextual infos +// Solidity: function v2_sendMessage(bytes xcm, bytes[] assets, bytes claimer) payable returns() +func (_Gateway *GatewayTransactorSession) V2SendMessage(xcm []byte, assets [][]byte, claimer []byte) (*types.Transaction, error) { + return _Gateway.Contract.V2SendMessage(&_Gateway.TransactOpts, xcm, assets, claimer) } -// FilterAgentCreated is a free log retrieval operation binding the contract event 0x7c96960a1ebd8cc753b10836ea25bd7c9c4f8cd43590db1e8b3648cb0ec4cc89. +// V2Submit is a paid mutator transaction binding the contract method 0x9a13f0e7. // -// Solidity: event AgentCreated(bytes32 agentID, address agent) -func (_Gateway *GatewayFilterer) FilterAgentCreated(opts *bind.FilterOpts) (*GatewayAgentCreatedIterator, error) { - - logs, sub, err := _Gateway.contract.FilterLogs(opts, "AgentCreated") - if err != nil { - return nil, err - } - return &GatewayAgentCreatedIterator{contract: _Gateway.contract, event: "AgentCreated", logs: logs, sub: sub}, nil +// Solidity: function v2_submit((bytes32,uint64,(uint8,uint64,bytes)[]) message, bytes32[] leafProof, ((bytes32,uint256,bytes32,bytes32,(uint256,bytes4,bytes)[]),(uint256,uint256,bytes32[]),(uint8,uint32,bytes32,uint64,uint32,bytes32),bytes32[],uint256) headerProof, bytes32 rewardAddress) returns() +func (_Gateway *GatewayTransactor) V2Submit(opts *bind.TransactOpts, message InboundMessage, leafProof [][32]byte, headerProof VerificationProof, rewardAddress [32]byte) (*types.Transaction, error) { + return _Gateway.contract.Transact(opts, "v2_submit", message, leafProof, headerProof, rewardAddress) } -// WatchAgentCreated is a free log subscription operation binding the contract event 0x7c96960a1ebd8cc753b10836ea25bd7c9c4f8cd43590db1e8b3648cb0ec4cc89. +// V2Submit is a paid mutator transaction binding the contract method 0x9a13f0e7. // -// Solidity: event AgentCreated(bytes32 agentID, address agent) -func (_Gateway *GatewayFilterer) WatchAgentCreated(opts *bind.WatchOpts, sink chan<- *GatewayAgentCreated) (event.Subscription, error) { - - logs, sub, err := _Gateway.contract.WatchLogs(opts, "AgentCreated") - 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(GatewayAgentCreated) - if err := _Gateway.contract.UnpackLog(event, "AgentCreated", 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 +// Solidity: function v2_submit((bytes32,uint64,(uint8,uint64,bytes)[]) message, bytes32[] leafProof, ((bytes32,uint256,bytes32,bytes32,(uint256,bytes4,bytes)[]),(uint256,uint256,bytes32[]),(uint8,uint32,bytes32,uint64,uint32,bytes32),bytes32[],uint256) headerProof, bytes32 rewardAddress) returns() +func (_Gateway *GatewaySession) V2Submit(message InboundMessage, leafProof [][32]byte, headerProof VerificationProof, rewardAddress [32]byte) (*types.Transaction, error) { + return _Gateway.Contract.V2Submit(&_Gateway.TransactOpts, message, leafProof, headerProof, rewardAddress) } -// ParseAgentCreated is a log parse operation binding the contract event 0x7c96960a1ebd8cc753b10836ea25bd7c9c4f8cd43590db1e8b3648cb0ec4cc89. +// V2Submit is a paid mutator transaction binding the contract method 0x9a13f0e7. // -// Solidity: event AgentCreated(bytes32 agentID, address agent) -func (_Gateway *GatewayFilterer) ParseAgentCreated(log types.Log) (*GatewayAgentCreated, error) { - event := new(GatewayAgentCreated) - if err := _Gateway.contract.UnpackLog(event, "AgentCreated", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil +// Solidity: function v2_submit((bytes32,uint64,(uint8,uint64,bytes)[]) message, bytes32[] leafProof, ((bytes32,uint256,bytes32,bytes32,(uint256,bytes4,bytes)[]),(uint256,uint256,bytes32[]),(uint8,uint32,bytes32,uint64,uint32,bytes32),bytes32[],uint256) headerProof, bytes32 rewardAddress) returns() +func (_Gateway *GatewayTransactorSession) V2Submit(message InboundMessage, leafProof [][32]byte, headerProof VerificationProof, rewardAddress [32]byte) (*types.Transaction, error) { + return _Gateway.Contract.V2Submit(&_Gateway.TransactOpts, message, leafProof, headerProof, rewardAddress) } -// GatewayAgentFundsWithdrawnIterator is returned from FilterAgentFundsWithdrawn and is used to iterate over the raw logs and unpacked data for AgentFundsWithdrawn events raised by the Gateway contract. -type GatewayAgentFundsWithdrawnIterator struct { - Event *GatewayAgentFundsWithdrawn // Event containing the contract specifics and raw log +// GatewayInboundMessageDispatchedIterator is returned from FilterInboundMessageDispatched and is used to iterate over the raw logs and unpacked data for InboundMessageDispatched events raised by the Gateway contract. +type GatewayInboundMessageDispatchedIterator struct { + Event *GatewayInboundMessageDispatched // 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 @@ -735,7 +491,7 @@ type GatewayAgentFundsWithdrawnIterator 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 *GatewayAgentFundsWithdrawnIterator) Next() bool { +func (it *GatewayInboundMessageDispatchedIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -744,7 +500,7 @@ func (it *GatewayAgentFundsWithdrawnIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(GatewayAgentFundsWithdrawn) + it.Event = new(GatewayInboundMessageDispatched) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -759,7 +515,7 @@ func (it *GatewayAgentFundsWithdrawnIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(GatewayAgentFundsWithdrawn) + it.Event = new(GatewayInboundMessageDispatched) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -775,61 +531,63 @@ func (it *GatewayAgentFundsWithdrawnIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *GatewayAgentFundsWithdrawnIterator) Error() error { +func (it *GatewayInboundMessageDispatchedIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *GatewayAgentFundsWithdrawnIterator) Close() error { +func (it *GatewayInboundMessageDispatchedIterator) Close() error { it.sub.Unsubscribe() return nil } -// GatewayAgentFundsWithdrawn represents a AgentFundsWithdrawn event raised by the Gateway contract. -type GatewayAgentFundsWithdrawn struct { - AgentID [32]byte - Recipient common.Address - Amount *big.Int - Raw types.Log // Blockchain specific contextual infos +// GatewayInboundMessageDispatched represents a InboundMessageDispatched event raised by the Gateway contract. +type GatewayInboundMessageDispatched struct { + Nonce uint64 + Success bool + RewardAddress [32]byte + Raw types.Log // Blockchain specific contextual infos } -// FilterAgentFundsWithdrawn is a free log retrieval operation binding the contract event 0xf953871855f78d5ccdd6268f2d9d69fc67f26542a35d2bba1c615521aed57054. +// FilterInboundMessageDispatched is a free log retrieval operation binding the contract event 0x755d3b4d173427dc415f2c82a71641bfdbc1e8f79e36a2bd0d480237e94a159b. // -// Solidity: event AgentFundsWithdrawn(bytes32 indexed agentID, address indexed recipient, uint256 amount) -func (_Gateway *GatewayFilterer) FilterAgentFundsWithdrawn(opts *bind.FilterOpts, agentID [][32]byte, recipient []common.Address) (*GatewayAgentFundsWithdrawnIterator, error) { +// Solidity: event InboundMessageDispatched(uint64 indexed nonce, bool success, bytes32 indexed rewardAddress) +func (_Gateway *GatewayFilterer) FilterInboundMessageDispatched(opts *bind.FilterOpts, nonce []uint64, rewardAddress [][32]byte) (*GatewayInboundMessageDispatchedIterator, error) { - var agentIDRule []interface{} - for _, agentIDItem := range agentID { - agentIDRule = append(agentIDRule, agentIDItem) + var nonceRule []interface{} + for _, nonceItem := range nonce { + nonceRule = append(nonceRule, nonceItem) } - var recipientRule []interface{} - for _, recipientItem := range recipient { - recipientRule = append(recipientRule, recipientItem) + + var rewardAddressRule []interface{} + for _, rewardAddressItem := range rewardAddress { + rewardAddressRule = append(rewardAddressRule, rewardAddressItem) } - logs, sub, err := _Gateway.contract.FilterLogs(opts, "AgentFundsWithdrawn", agentIDRule, recipientRule) + logs, sub, err := _Gateway.contract.FilterLogs(opts, "InboundMessageDispatched", nonceRule, rewardAddressRule) if err != nil { return nil, err } - return &GatewayAgentFundsWithdrawnIterator{contract: _Gateway.contract, event: "AgentFundsWithdrawn", logs: logs, sub: sub}, nil + return &GatewayInboundMessageDispatchedIterator{contract: _Gateway.contract, event: "InboundMessageDispatched", logs: logs, sub: sub}, nil } -// WatchAgentFundsWithdrawn is a free log subscription operation binding the contract event 0xf953871855f78d5ccdd6268f2d9d69fc67f26542a35d2bba1c615521aed57054. +// WatchInboundMessageDispatched is a free log subscription operation binding the contract event 0x755d3b4d173427dc415f2c82a71641bfdbc1e8f79e36a2bd0d480237e94a159b. // -// Solidity: event AgentFundsWithdrawn(bytes32 indexed agentID, address indexed recipient, uint256 amount) -func (_Gateway *GatewayFilterer) WatchAgentFundsWithdrawn(opts *bind.WatchOpts, sink chan<- *GatewayAgentFundsWithdrawn, agentID [][32]byte, recipient []common.Address) (event.Subscription, error) { +// Solidity: event InboundMessageDispatched(uint64 indexed nonce, bool success, bytes32 indexed rewardAddress) +func (_Gateway *GatewayFilterer) WatchInboundMessageDispatched(opts *bind.WatchOpts, sink chan<- *GatewayInboundMessageDispatched, nonce []uint64, rewardAddress [][32]byte) (event.Subscription, error) { - var agentIDRule []interface{} - for _, agentIDItem := range agentID { - agentIDRule = append(agentIDRule, agentIDItem) + var nonceRule []interface{} + for _, nonceItem := range nonce { + nonceRule = append(nonceRule, nonceItem) } - var recipientRule []interface{} - for _, recipientItem := range recipient { - recipientRule = append(recipientRule, recipientItem) + + var rewardAddressRule []interface{} + for _, rewardAddressItem := range rewardAddress { + rewardAddressRule = append(rewardAddressRule, rewardAddressItem) } - logs, sub, err := _Gateway.contract.WatchLogs(opts, "AgentFundsWithdrawn", agentIDRule, recipientRule) + logs, sub, err := _Gateway.contract.WatchLogs(opts, "InboundMessageDispatched", nonceRule, rewardAddressRule) if err != nil { return nil, err } @@ -839,8 +597,8 @@ func (_Gateway *GatewayFilterer) WatchAgentFundsWithdrawn(opts *bind.WatchOpts, select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(GatewayAgentFundsWithdrawn) - if err := _Gateway.contract.UnpackLog(event, "AgentFundsWithdrawn", log); err != nil { + event := new(GatewayInboundMessageDispatched) + if err := _Gateway.contract.UnpackLog(event, "InboundMessageDispatched", log); err != nil { return err } event.Raw = log @@ -861,21 +619,21 @@ func (_Gateway *GatewayFilterer) WatchAgentFundsWithdrawn(opts *bind.WatchOpts, }), nil } -// ParseAgentFundsWithdrawn is a log parse operation binding the contract event 0xf953871855f78d5ccdd6268f2d9d69fc67f26542a35d2bba1c615521aed57054. +// ParseInboundMessageDispatched is a log parse operation binding the contract event 0x755d3b4d173427dc415f2c82a71641bfdbc1e8f79e36a2bd0d480237e94a159b. // -// Solidity: event AgentFundsWithdrawn(bytes32 indexed agentID, address indexed recipient, uint256 amount) -func (_Gateway *GatewayFilterer) ParseAgentFundsWithdrawn(log types.Log) (*GatewayAgentFundsWithdrawn, error) { - event := new(GatewayAgentFundsWithdrawn) - if err := _Gateway.contract.UnpackLog(event, "AgentFundsWithdrawn", log); err != nil { +// Solidity: event InboundMessageDispatched(uint64 indexed nonce, bool success, bytes32 indexed rewardAddress) +func (_Gateway *GatewayFilterer) ParseInboundMessageDispatched(log types.Log) (*GatewayInboundMessageDispatched, error) { + event := new(GatewayInboundMessageDispatched) + if err := _Gateway.contract.UnpackLog(event, "InboundMessageDispatched", log); err != nil { return nil, err } event.Raw = log return event, nil } -// GatewayChannelCreatedIterator is returned from FilterChannelCreated and is used to iterate over the raw logs and unpacked data for ChannelCreated events raised by the Gateway contract. -type GatewayChannelCreatedIterator struct { - Event *GatewayChannelCreated // Event containing the contract specifics and raw log +// GatewayOutboundMessageAcceptedIterator is returned from FilterOutboundMessageAccepted and is used to iterate over the raw logs and unpacked data for OutboundMessageAccepted events raised by the Gateway contract. +type GatewayOutboundMessageAcceptedIterator struct { + Event *GatewayOutboundMessageAccepted // 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 @@ -889,7 +647,7 @@ type GatewayChannelCreatedIterator 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 *GatewayChannelCreatedIterator) Next() bool { +func (it *GatewayOutboundMessageAcceptedIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -898,7 +656,7 @@ func (it *GatewayChannelCreatedIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(GatewayChannelCreated) + it.Event = new(GatewayOutboundMessageAccepted) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -913,7 +671,7 @@ func (it *GatewayChannelCreatedIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(GatewayChannelCreated) + it.Event = new(GatewayOutboundMessageAccepted) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -929,51 +687,43 @@ func (it *GatewayChannelCreatedIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *GatewayChannelCreatedIterator) Error() error { +func (it *GatewayOutboundMessageAcceptedIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *GatewayChannelCreatedIterator) Close() error { +func (it *GatewayOutboundMessageAcceptedIterator) Close() error { it.sub.Unsubscribe() return nil } -// GatewayChannelCreated represents a ChannelCreated event raised by the Gateway contract. -type GatewayChannelCreated struct { - ChannelID [32]byte - Raw types.Log // Blockchain specific contextual infos +// GatewayOutboundMessageAccepted represents a OutboundMessageAccepted event raised by the Gateway contract. +type GatewayOutboundMessageAccepted struct { + Nonce uint64 + Reward *big.Int + Payload []byte + Raw types.Log // Blockchain specific contextual infos } -// FilterChannelCreated is a free log retrieval operation binding the contract event 0xe7e6b36c9bc4c7817d3879c45d6ce1edd3c61b1966c488f1817697bb0b704525. +// FilterOutboundMessageAccepted is a free log retrieval operation binding the contract event 0xf2297c2b692d37814ed50b9ff0f52bf87ab5d1692a651f2a9ee8a872fdea1dda. // -// Solidity: event ChannelCreated(bytes32 indexed channelID) -func (_Gateway *GatewayFilterer) FilterChannelCreated(opts *bind.FilterOpts, channelID [][32]byte) (*GatewayChannelCreatedIterator, error) { - - var channelIDRule []interface{} - for _, channelIDItem := range channelID { - channelIDRule = append(channelIDRule, channelIDItem) - } +// Solidity: event OutboundMessageAccepted(uint64 nonce, uint256 reward, bytes payload) +func (_Gateway *GatewayFilterer) FilterOutboundMessageAccepted(opts *bind.FilterOpts) (*GatewayOutboundMessageAcceptedIterator, error) { - logs, sub, err := _Gateway.contract.FilterLogs(opts, "ChannelCreated", channelIDRule) + logs, sub, err := _Gateway.contract.FilterLogs(opts, "OutboundMessageAccepted") if err != nil { return nil, err } - return &GatewayChannelCreatedIterator{contract: _Gateway.contract, event: "ChannelCreated", logs: logs, sub: sub}, nil + return &GatewayOutboundMessageAcceptedIterator{contract: _Gateway.contract, event: "OutboundMessageAccepted", logs: logs, sub: sub}, nil } -// WatchChannelCreated is a free log subscription operation binding the contract event 0xe7e6b36c9bc4c7817d3879c45d6ce1edd3c61b1966c488f1817697bb0b704525. +// WatchOutboundMessageAccepted is a free log subscription operation binding the contract event 0xf2297c2b692d37814ed50b9ff0f52bf87ab5d1692a651f2a9ee8a872fdea1dda. // -// Solidity: event ChannelCreated(bytes32 indexed channelID) -func (_Gateway *GatewayFilterer) WatchChannelCreated(opts *bind.WatchOpts, sink chan<- *GatewayChannelCreated, channelID [][32]byte) (event.Subscription, error) { +// Solidity: event OutboundMessageAccepted(uint64 nonce, uint256 reward, bytes payload) +func (_Gateway *GatewayFilterer) WatchOutboundMessageAccepted(opts *bind.WatchOpts, sink chan<- *GatewayOutboundMessageAccepted) (event.Subscription, error) { - var channelIDRule []interface{} - for _, channelIDItem := range channelID { - channelIDRule = append(channelIDRule, channelIDItem) - } - - logs, sub, err := _Gateway.contract.WatchLogs(opts, "ChannelCreated", channelIDRule) + logs, sub, err := _Gateway.contract.WatchLogs(opts, "OutboundMessageAccepted") if err != nil { return nil, err } @@ -983,8 +733,8 @@ func (_Gateway *GatewayFilterer) WatchChannelCreated(opts *bind.WatchOpts, sink select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(GatewayChannelCreated) - if err := _Gateway.contract.UnpackLog(event, "ChannelCreated", log); err != nil { + event := new(GatewayOutboundMessageAccepted) + if err := _Gateway.contract.UnpackLog(event, "OutboundMessageAccepted", log); err != nil { return err } event.Raw = log @@ -1005,1313 +755,12 @@ func (_Gateway *GatewayFilterer) WatchChannelCreated(opts *bind.WatchOpts, sink }), nil } -// ParseChannelCreated is a log parse operation binding the contract event 0xe7e6b36c9bc4c7817d3879c45d6ce1edd3c61b1966c488f1817697bb0b704525. +// ParseOutboundMessageAccepted is a log parse operation binding the contract event 0xf2297c2b692d37814ed50b9ff0f52bf87ab5d1692a651f2a9ee8a872fdea1dda. // -// Solidity: event ChannelCreated(bytes32 indexed channelID) -func (_Gateway *GatewayFilterer) ParseChannelCreated(log types.Log) (*GatewayChannelCreated, error) { - event := new(GatewayChannelCreated) - if err := _Gateway.contract.UnpackLog(event, "ChannelCreated", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// GatewayChannelUpdatedIterator is returned from FilterChannelUpdated and is used to iterate over the raw logs and unpacked data for ChannelUpdated events raised by the Gateway contract. -type GatewayChannelUpdatedIterator struct { - Event *GatewayChannelUpdated // 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 *GatewayChannelUpdatedIterator) 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(GatewayChannelUpdated) - 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(GatewayChannelUpdated) - 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 *GatewayChannelUpdatedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *GatewayChannelUpdatedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// GatewayChannelUpdated represents a ChannelUpdated event raised by the Gateway contract. -type GatewayChannelUpdated struct { - ChannelID [32]byte - Raw types.Log // Blockchain specific contextual infos -} - -// FilterChannelUpdated is a free log retrieval operation binding the contract event 0x66e174b5e03ba247add8660a34e70bdd484239fe794c2567772e8e93a5c1696b. -// -// Solidity: event ChannelUpdated(bytes32 indexed channelID) -func (_Gateway *GatewayFilterer) FilterChannelUpdated(opts *bind.FilterOpts, channelID [][32]byte) (*GatewayChannelUpdatedIterator, error) { - - var channelIDRule []interface{} - for _, channelIDItem := range channelID { - channelIDRule = append(channelIDRule, channelIDItem) - } - - logs, sub, err := _Gateway.contract.FilterLogs(opts, "ChannelUpdated", channelIDRule) - if err != nil { - return nil, err - } - return &GatewayChannelUpdatedIterator{contract: _Gateway.contract, event: "ChannelUpdated", logs: logs, sub: sub}, nil -} - -// WatchChannelUpdated is a free log subscription operation binding the contract event 0x66e174b5e03ba247add8660a34e70bdd484239fe794c2567772e8e93a5c1696b. -// -// Solidity: event ChannelUpdated(bytes32 indexed channelID) -func (_Gateway *GatewayFilterer) WatchChannelUpdated(opts *bind.WatchOpts, sink chan<- *GatewayChannelUpdated, channelID [][32]byte) (event.Subscription, error) { - - var channelIDRule []interface{} - for _, channelIDItem := range channelID { - channelIDRule = append(channelIDRule, channelIDItem) - } - - logs, sub, err := _Gateway.contract.WatchLogs(opts, "ChannelUpdated", channelIDRule) - 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(GatewayChannelUpdated) - if err := _Gateway.contract.UnpackLog(event, "ChannelUpdated", 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 -} - -// ParseChannelUpdated is a log parse operation binding the contract event 0x66e174b5e03ba247add8660a34e70bdd484239fe794c2567772e8e93a5c1696b. -// -// Solidity: event ChannelUpdated(bytes32 indexed channelID) -func (_Gateway *GatewayFilterer) ParseChannelUpdated(log types.Log) (*GatewayChannelUpdated, error) { - event := new(GatewayChannelUpdated) - if err := _Gateway.contract.UnpackLog(event, "ChannelUpdated", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// GatewayForeignTokenRegisteredIterator is returned from FilterForeignTokenRegistered and is used to iterate over the raw logs and unpacked data for ForeignTokenRegistered events raised by the Gateway contract. -type GatewayForeignTokenRegisteredIterator struct { - Event *GatewayForeignTokenRegistered // 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 *GatewayForeignTokenRegisteredIterator) 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(GatewayForeignTokenRegistered) - 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(GatewayForeignTokenRegistered) - 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 *GatewayForeignTokenRegisteredIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *GatewayForeignTokenRegisteredIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// GatewayForeignTokenRegistered represents a ForeignTokenRegistered event raised by the Gateway contract. -type GatewayForeignTokenRegistered struct { - TokenID [32]byte - Token common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterForeignTokenRegistered is a free log retrieval operation binding the contract event 0x57f58171b8777633d03aff1e7408b96a3d910c93a7ce433a8cb7fb837dc306a6. -// -// Solidity: event ForeignTokenRegistered(bytes32 indexed tokenID, address token) -func (_Gateway *GatewayFilterer) FilterForeignTokenRegistered(opts *bind.FilterOpts, tokenID [][32]byte) (*GatewayForeignTokenRegisteredIterator, error) { - - var tokenIDRule []interface{} - for _, tokenIDItem := range tokenID { - tokenIDRule = append(tokenIDRule, tokenIDItem) - } - - logs, sub, err := _Gateway.contract.FilterLogs(opts, "ForeignTokenRegistered", tokenIDRule) - if err != nil { - return nil, err - } - return &GatewayForeignTokenRegisteredIterator{contract: _Gateway.contract, event: "ForeignTokenRegistered", logs: logs, sub: sub}, nil -} - -// WatchForeignTokenRegistered is a free log subscription operation binding the contract event 0x57f58171b8777633d03aff1e7408b96a3d910c93a7ce433a8cb7fb837dc306a6. -// -// Solidity: event ForeignTokenRegistered(bytes32 indexed tokenID, address token) -func (_Gateway *GatewayFilterer) WatchForeignTokenRegistered(opts *bind.WatchOpts, sink chan<- *GatewayForeignTokenRegistered, tokenID [][32]byte) (event.Subscription, error) { - - var tokenIDRule []interface{} - for _, tokenIDItem := range tokenID { - tokenIDRule = append(tokenIDRule, tokenIDItem) - } - - logs, sub, err := _Gateway.contract.WatchLogs(opts, "ForeignTokenRegistered", tokenIDRule) - 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(GatewayForeignTokenRegistered) - if err := _Gateway.contract.UnpackLog(event, "ForeignTokenRegistered", 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 -} - -// ParseForeignTokenRegistered is a log parse operation binding the contract event 0x57f58171b8777633d03aff1e7408b96a3d910c93a7ce433a8cb7fb837dc306a6. -// -// Solidity: event ForeignTokenRegistered(bytes32 indexed tokenID, address token) -func (_Gateway *GatewayFilterer) ParseForeignTokenRegistered(log types.Log) (*GatewayForeignTokenRegistered, error) { - event := new(GatewayForeignTokenRegistered) - if err := _Gateway.contract.UnpackLog(event, "ForeignTokenRegistered", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// GatewayInboundMessageDispatchedIterator is returned from FilterInboundMessageDispatched and is used to iterate over the raw logs and unpacked data for InboundMessageDispatched events raised by the Gateway contract. -type GatewayInboundMessageDispatchedIterator struct { - Event *GatewayInboundMessageDispatched // 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 *GatewayInboundMessageDispatchedIterator) 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(GatewayInboundMessageDispatched) - 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(GatewayInboundMessageDispatched) - 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 *GatewayInboundMessageDispatchedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *GatewayInboundMessageDispatchedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// GatewayInboundMessageDispatched represents a InboundMessageDispatched event raised by the Gateway contract. -type GatewayInboundMessageDispatched struct { - ChannelID [32]byte - Nonce uint64 - MessageID [32]byte - Success bool - Raw types.Log // Blockchain specific contextual infos -} - -// FilterInboundMessageDispatched is a free log retrieval operation binding the contract event 0x617fdb0cb78f01551a192a3673208ec5eb09f20a90acf673c63a0dcb11745a7a. -// -// Solidity: event InboundMessageDispatched(bytes32 indexed channelID, uint64 nonce, bytes32 indexed messageID, bool success) -func (_Gateway *GatewayFilterer) FilterInboundMessageDispatched(opts *bind.FilterOpts, channelID [][32]byte, messageID [][32]byte) (*GatewayInboundMessageDispatchedIterator, error) { - - var channelIDRule []interface{} - for _, channelIDItem := range channelID { - channelIDRule = append(channelIDRule, channelIDItem) - } - - var messageIDRule []interface{} - for _, messageIDItem := range messageID { - messageIDRule = append(messageIDRule, messageIDItem) - } - - logs, sub, err := _Gateway.contract.FilterLogs(opts, "InboundMessageDispatched", channelIDRule, messageIDRule) - if err != nil { - return nil, err - } - return &GatewayInboundMessageDispatchedIterator{contract: _Gateway.contract, event: "InboundMessageDispatched", logs: logs, sub: sub}, nil -} - -// WatchInboundMessageDispatched is a free log subscription operation binding the contract event 0x617fdb0cb78f01551a192a3673208ec5eb09f20a90acf673c63a0dcb11745a7a. -// -// Solidity: event InboundMessageDispatched(bytes32 indexed channelID, uint64 nonce, bytes32 indexed messageID, bool success) -func (_Gateway *GatewayFilterer) WatchInboundMessageDispatched(opts *bind.WatchOpts, sink chan<- *GatewayInboundMessageDispatched, channelID [][32]byte, messageID [][32]byte) (event.Subscription, error) { - - var channelIDRule []interface{} - for _, channelIDItem := range channelID { - channelIDRule = append(channelIDRule, channelIDItem) - } - - var messageIDRule []interface{} - for _, messageIDItem := range messageID { - messageIDRule = append(messageIDRule, messageIDItem) - } - - logs, sub, err := _Gateway.contract.WatchLogs(opts, "InboundMessageDispatched", channelIDRule, messageIDRule) - 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(GatewayInboundMessageDispatched) - if err := _Gateway.contract.UnpackLog(event, "InboundMessageDispatched", 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 -} - -// ParseInboundMessageDispatched is a log parse operation binding the contract event 0x617fdb0cb78f01551a192a3673208ec5eb09f20a90acf673c63a0dcb11745a7a. -// -// Solidity: event InboundMessageDispatched(bytes32 indexed channelID, uint64 nonce, bytes32 indexed messageID, bool success) -func (_Gateway *GatewayFilterer) ParseInboundMessageDispatched(log types.Log) (*GatewayInboundMessageDispatched, error) { - event := new(GatewayInboundMessageDispatched) - if err := _Gateway.contract.UnpackLog(event, "InboundMessageDispatched", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// GatewayOperatingModeChangedIterator is returned from FilterOperatingModeChanged and is used to iterate over the raw logs and unpacked data for OperatingModeChanged events raised by the Gateway contract. -type GatewayOperatingModeChangedIterator struct { - Event *GatewayOperatingModeChanged // 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 *GatewayOperatingModeChangedIterator) 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(GatewayOperatingModeChanged) - 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(GatewayOperatingModeChanged) - 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 *GatewayOperatingModeChangedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *GatewayOperatingModeChangedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// GatewayOperatingModeChanged represents a OperatingModeChanged event raised by the Gateway contract. -type GatewayOperatingModeChanged struct { - Mode uint8 - Raw types.Log // Blockchain specific contextual infos -} - -// FilterOperatingModeChanged is a free log retrieval operation binding the contract event 0x4016a1377b8961c4aa6f3a2d3de830a685ddbfe0f228ffc0208eb96304c4cf1a. -// -// Solidity: event OperatingModeChanged(uint8 mode) -func (_Gateway *GatewayFilterer) FilterOperatingModeChanged(opts *bind.FilterOpts) (*GatewayOperatingModeChangedIterator, error) { - - logs, sub, err := _Gateway.contract.FilterLogs(opts, "OperatingModeChanged") - if err != nil { - return nil, err - } - return &GatewayOperatingModeChangedIterator{contract: _Gateway.contract, event: "OperatingModeChanged", logs: logs, sub: sub}, nil -} - -// WatchOperatingModeChanged is a free log subscription operation binding the contract event 0x4016a1377b8961c4aa6f3a2d3de830a685ddbfe0f228ffc0208eb96304c4cf1a. -// -// Solidity: event OperatingModeChanged(uint8 mode) -func (_Gateway *GatewayFilterer) WatchOperatingModeChanged(opts *bind.WatchOpts, sink chan<- *GatewayOperatingModeChanged) (event.Subscription, error) { - - logs, sub, err := _Gateway.contract.WatchLogs(opts, "OperatingModeChanged") - 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(GatewayOperatingModeChanged) - if err := _Gateway.contract.UnpackLog(event, "OperatingModeChanged", 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 -} - -// ParseOperatingModeChanged is a log parse operation binding the contract event 0x4016a1377b8961c4aa6f3a2d3de830a685ddbfe0f228ffc0208eb96304c4cf1a. -// -// Solidity: event OperatingModeChanged(uint8 mode) -func (_Gateway *GatewayFilterer) ParseOperatingModeChanged(log types.Log) (*GatewayOperatingModeChanged, error) { - event := new(GatewayOperatingModeChanged) - if err := _Gateway.contract.UnpackLog(event, "OperatingModeChanged", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// GatewayOutboundMessageAcceptedIterator is returned from FilterOutboundMessageAccepted and is used to iterate over the raw logs and unpacked data for OutboundMessageAccepted events raised by the Gateway contract. -type GatewayOutboundMessageAcceptedIterator struct { - Event *GatewayOutboundMessageAccepted // 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 *GatewayOutboundMessageAcceptedIterator) 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(GatewayOutboundMessageAccepted) - 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(GatewayOutboundMessageAccepted) - 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 *GatewayOutboundMessageAcceptedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *GatewayOutboundMessageAcceptedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// GatewayOutboundMessageAccepted represents a OutboundMessageAccepted event raised by the Gateway contract. -type GatewayOutboundMessageAccepted struct { - ChannelID [32]byte - Nonce uint64 - MessageID [32]byte - Payload []byte - Raw types.Log // Blockchain specific contextual infos -} - -// FilterOutboundMessageAccepted is a free log retrieval operation binding the contract event 0x7153f9357c8ea496bba60bf82e67143e27b64462b49041f8e689e1b05728f84f. -// -// Solidity: event OutboundMessageAccepted(bytes32 indexed channelID, uint64 nonce, bytes32 indexed messageID, bytes payload) -func (_Gateway *GatewayFilterer) FilterOutboundMessageAccepted(opts *bind.FilterOpts, channelID [][32]byte, messageID [][32]byte) (*GatewayOutboundMessageAcceptedIterator, error) { - - var channelIDRule []interface{} - for _, channelIDItem := range channelID { - channelIDRule = append(channelIDRule, channelIDItem) - } - - var messageIDRule []interface{} - for _, messageIDItem := range messageID { - messageIDRule = append(messageIDRule, messageIDItem) - } - - logs, sub, err := _Gateway.contract.FilterLogs(opts, "OutboundMessageAccepted", channelIDRule, messageIDRule) - if err != nil { - return nil, err - } - return &GatewayOutboundMessageAcceptedIterator{contract: _Gateway.contract, event: "OutboundMessageAccepted", logs: logs, sub: sub}, nil -} - -// WatchOutboundMessageAccepted is a free log subscription operation binding the contract event 0x7153f9357c8ea496bba60bf82e67143e27b64462b49041f8e689e1b05728f84f. -// -// Solidity: event OutboundMessageAccepted(bytes32 indexed channelID, uint64 nonce, bytes32 indexed messageID, bytes payload) -func (_Gateway *GatewayFilterer) WatchOutboundMessageAccepted(opts *bind.WatchOpts, sink chan<- *GatewayOutboundMessageAccepted, channelID [][32]byte, messageID [][32]byte) (event.Subscription, error) { - - var channelIDRule []interface{} - for _, channelIDItem := range channelID { - channelIDRule = append(channelIDRule, channelIDItem) - } - - var messageIDRule []interface{} - for _, messageIDItem := range messageID { - messageIDRule = append(messageIDRule, messageIDItem) - } - - logs, sub, err := _Gateway.contract.WatchLogs(opts, "OutboundMessageAccepted", channelIDRule, messageIDRule) - 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(GatewayOutboundMessageAccepted) - if err := _Gateway.contract.UnpackLog(event, "OutboundMessageAccepted", 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 -} - -// ParseOutboundMessageAccepted is a log parse operation binding the contract event 0x7153f9357c8ea496bba60bf82e67143e27b64462b49041f8e689e1b05728f84f. -// -// Solidity: event OutboundMessageAccepted(bytes32 indexed channelID, uint64 nonce, bytes32 indexed messageID, bytes payload) -func (_Gateway *GatewayFilterer) ParseOutboundMessageAccepted(log types.Log) (*GatewayOutboundMessageAccepted, error) { - event := new(GatewayOutboundMessageAccepted) - if err := _Gateway.contract.UnpackLog(event, "OutboundMessageAccepted", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// GatewayPricingParametersChangedIterator is returned from FilterPricingParametersChanged and is used to iterate over the raw logs and unpacked data for PricingParametersChanged events raised by the Gateway contract. -type GatewayPricingParametersChangedIterator struct { - Event *GatewayPricingParametersChanged // 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 *GatewayPricingParametersChangedIterator) 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(GatewayPricingParametersChanged) - 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(GatewayPricingParametersChanged) - 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 *GatewayPricingParametersChangedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *GatewayPricingParametersChangedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// GatewayPricingParametersChanged represents a PricingParametersChanged event raised by the Gateway contract. -type GatewayPricingParametersChanged struct { - Raw types.Log // Blockchain specific contextual infos -} - -// FilterPricingParametersChanged is a free log retrieval operation binding the contract event 0x5e3c25378b5946068b94aa2ea10c4c1e215cc975f994322b159ddc9237a973d4. -// -// Solidity: event PricingParametersChanged() -func (_Gateway *GatewayFilterer) FilterPricingParametersChanged(opts *bind.FilterOpts) (*GatewayPricingParametersChangedIterator, error) { - - logs, sub, err := _Gateway.contract.FilterLogs(opts, "PricingParametersChanged") - if err != nil { - return nil, err - } - return &GatewayPricingParametersChangedIterator{contract: _Gateway.contract, event: "PricingParametersChanged", logs: logs, sub: sub}, nil -} - -// WatchPricingParametersChanged is a free log subscription operation binding the contract event 0x5e3c25378b5946068b94aa2ea10c4c1e215cc975f994322b159ddc9237a973d4. -// -// Solidity: event PricingParametersChanged() -func (_Gateway *GatewayFilterer) WatchPricingParametersChanged(opts *bind.WatchOpts, sink chan<- *GatewayPricingParametersChanged) (event.Subscription, error) { - - logs, sub, err := _Gateway.contract.WatchLogs(opts, "PricingParametersChanged") - 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(GatewayPricingParametersChanged) - if err := _Gateway.contract.UnpackLog(event, "PricingParametersChanged", 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 -} - -// ParsePricingParametersChanged is a log parse operation binding the contract event 0x5e3c25378b5946068b94aa2ea10c4c1e215cc975f994322b159ddc9237a973d4. -// -// Solidity: event PricingParametersChanged() -func (_Gateway *GatewayFilterer) ParsePricingParametersChanged(log types.Log) (*GatewayPricingParametersChanged, error) { - event := new(GatewayPricingParametersChanged) - if err := _Gateway.contract.UnpackLog(event, "PricingParametersChanged", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// GatewayTokenRegistrationSentIterator is returned from FilterTokenRegistrationSent and is used to iterate over the raw logs and unpacked data for TokenRegistrationSent events raised by the Gateway contract. -type GatewayTokenRegistrationSentIterator struct { - Event *GatewayTokenRegistrationSent // 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 *GatewayTokenRegistrationSentIterator) 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(GatewayTokenRegistrationSent) - 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(GatewayTokenRegistrationSent) - 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 *GatewayTokenRegistrationSentIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *GatewayTokenRegistrationSentIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// GatewayTokenRegistrationSent represents a TokenRegistrationSent event raised by the Gateway contract. -type GatewayTokenRegistrationSent struct { - Token common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterTokenRegistrationSent is a free log retrieval operation binding the contract event 0xf78bb28d4b1d7da699e5c0bc2be29c2b04b5aab6aacf6298fe5304f9db9c6d7e. -// -// Solidity: event TokenRegistrationSent(address token) -func (_Gateway *GatewayFilterer) FilterTokenRegistrationSent(opts *bind.FilterOpts) (*GatewayTokenRegistrationSentIterator, error) { - - logs, sub, err := _Gateway.contract.FilterLogs(opts, "TokenRegistrationSent") - if err != nil { - return nil, err - } - return &GatewayTokenRegistrationSentIterator{contract: _Gateway.contract, event: "TokenRegistrationSent", logs: logs, sub: sub}, nil -} - -// WatchTokenRegistrationSent is a free log subscription operation binding the contract event 0xf78bb28d4b1d7da699e5c0bc2be29c2b04b5aab6aacf6298fe5304f9db9c6d7e. -// -// Solidity: event TokenRegistrationSent(address token) -func (_Gateway *GatewayFilterer) WatchTokenRegistrationSent(opts *bind.WatchOpts, sink chan<- *GatewayTokenRegistrationSent) (event.Subscription, error) { - - logs, sub, err := _Gateway.contract.WatchLogs(opts, "TokenRegistrationSent") - 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(GatewayTokenRegistrationSent) - if err := _Gateway.contract.UnpackLog(event, "TokenRegistrationSent", 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 -} - -// ParseTokenRegistrationSent is a log parse operation binding the contract event 0xf78bb28d4b1d7da699e5c0bc2be29c2b04b5aab6aacf6298fe5304f9db9c6d7e. -// -// Solidity: event TokenRegistrationSent(address token) -func (_Gateway *GatewayFilterer) ParseTokenRegistrationSent(log types.Log) (*GatewayTokenRegistrationSent, error) { - event := new(GatewayTokenRegistrationSent) - if err := _Gateway.contract.UnpackLog(event, "TokenRegistrationSent", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// GatewayTokenSentIterator is returned from FilterTokenSent and is used to iterate over the raw logs and unpacked data for TokenSent events raised by the Gateway contract. -type GatewayTokenSentIterator struct { - Event *GatewayTokenSent // 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 *GatewayTokenSentIterator) 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(GatewayTokenSent) - 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(GatewayTokenSent) - 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 *GatewayTokenSentIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *GatewayTokenSentIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// GatewayTokenSent represents a TokenSent event raised by the Gateway contract. -type GatewayTokenSent struct { - Token common.Address - Sender common.Address - DestinationChain uint32 - DestinationAddress MultiAddress - Amount *big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterTokenSent is a free log retrieval operation binding the contract event 0x24c5d2de620c6e25186ae16f6919eba93b6e2c1a33857cc419d9f3a00d6967e9. -// -// Solidity: event TokenSent(address indexed token, address indexed sender, uint32 indexed destinationChain, (uint8,bytes) destinationAddress, uint128 amount) -func (_Gateway *GatewayFilterer) FilterTokenSent(opts *bind.FilterOpts, token []common.Address, sender []common.Address, destinationChain []uint32) (*GatewayTokenSentIterator, error) { - - var tokenRule []interface{} - for _, tokenItem := range token { - tokenRule = append(tokenRule, tokenItem) - } - var senderRule []interface{} - for _, senderItem := range sender { - senderRule = append(senderRule, senderItem) - } - var destinationChainRule []interface{} - for _, destinationChainItem := range destinationChain { - destinationChainRule = append(destinationChainRule, destinationChainItem) - } - - logs, sub, err := _Gateway.contract.FilterLogs(opts, "TokenSent", tokenRule, senderRule, destinationChainRule) - if err != nil { - return nil, err - } - return &GatewayTokenSentIterator{contract: _Gateway.contract, event: "TokenSent", logs: logs, sub: sub}, nil -} - -// WatchTokenSent is a free log subscription operation binding the contract event 0x24c5d2de620c6e25186ae16f6919eba93b6e2c1a33857cc419d9f3a00d6967e9. -// -// Solidity: event TokenSent(address indexed token, address indexed sender, uint32 indexed destinationChain, (uint8,bytes) destinationAddress, uint128 amount) -func (_Gateway *GatewayFilterer) WatchTokenSent(opts *bind.WatchOpts, sink chan<- *GatewayTokenSent, token []common.Address, sender []common.Address, destinationChain []uint32) (event.Subscription, error) { - - var tokenRule []interface{} - for _, tokenItem := range token { - tokenRule = append(tokenRule, tokenItem) - } - var senderRule []interface{} - for _, senderItem := range sender { - senderRule = append(senderRule, senderItem) - } - var destinationChainRule []interface{} - for _, destinationChainItem := range destinationChain { - destinationChainRule = append(destinationChainRule, destinationChainItem) - } - - logs, sub, err := _Gateway.contract.WatchLogs(opts, "TokenSent", tokenRule, senderRule, destinationChainRule) - 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(GatewayTokenSent) - if err := _Gateway.contract.UnpackLog(event, "TokenSent", 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 -} - -// ParseTokenSent is a log parse operation binding the contract event 0x24c5d2de620c6e25186ae16f6919eba93b6e2c1a33857cc419d9f3a00d6967e9. -// -// Solidity: event TokenSent(address indexed token, address indexed sender, uint32 indexed destinationChain, (uint8,bytes) destinationAddress, uint128 amount) -func (_Gateway *GatewayFilterer) ParseTokenSent(log types.Log) (*GatewayTokenSent, error) { - event := new(GatewayTokenSent) - if err := _Gateway.contract.UnpackLog(event, "TokenSent", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// GatewayTokenTransferFeesChangedIterator is returned from FilterTokenTransferFeesChanged and is used to iterate over the raw logs and unpacked data for TokenTransferFeesChanged events raised by the Gateway contract. -type GatewayTokenTransferFeesChangedIterator struct { - Event *GatewayTokenTransferFeesChanged // 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 *GatewayTokenTransferFeesChangedIterator) 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(GatewayTokenTransferFeesChanged) - 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(GatewayTokenTransferFeesChanged) - 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 *GatewayTokenTransferFeesChangedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *GatewayTokenTransferFeesChangedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// GatewayTokenTransferFeesChanged represents a TokenTransferFeesChanged event raised by the Gateway contract. -type GatewayTokenTransferFeesChanged struct { - Raw types.Log // Blockchain specific contextual infos -} - -// FilterTokenTransferFeesChanged is a free log retrieval operation binding the contract event 0x4793c0cb5bef4b1fdbbfbcf17e06991844eb881088b012442af17a12ff38d5cd. -// -// Solidity: event TokenTransferFeesChanged() -func (_Gateway *GatewayFilterer) FilterTokenTransferFeesChanged(opts *bind.FilterOpts) (*GatewayTokenTransferFeesChangedIterator, error) { - - logs, sub, err := _Gateway.contract.FilterLogs(opts, "TokenTransferFeesChanged") - if err != nil { - return nil, err - } - return &GatewayTokenTransferFeesChangedIterator{contract: _Gateway.contract, event: "TokenTransferFeesChanged", logs: logs, sub: sub}, nil -} - -// WatchTokenTransferFeesChanged is a free log subscription operation binding the contract event 0x4793c0cb5bef4b1fdbbfbcf17e06991844eb881088b012442af17a12ff38d5cd. -// -// Solidity: event TokenTransferFeesChanged() -func (_Gateway *GatewayFilterer) WatchTokenTransferFeesChanged(opts *bind.WatchOpts, sink chan<- *GatewayTokenTransferFeesChanged) (event.Subscription, error) { - - logs, sub, err := _Gateway.contract.WatchLogs(opts, "TokenTransferFeesChanged") - 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(GatewayTokenTransferFeesChanged) - if err := _Gateway.contract.UnpackLog(event, "TokenTransferFeesChanged", 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 -} - -// ParseTokenTransferFeesChanged is a log parse operation binding the contract event 0x4793c0cb5bef4b1fdbbfbcf17e06991844eb881088b012442af17a12ff38d5cd. -// -// Solidity: event TokenTransferFeesChanged() -func (_Gateway *GatewayFilterer) ParseTokenTransferFeesChanged(log types.Log) (*GatewayTokenTransferFeesChanged, error) { - event := new(GatewayTokenTransferFeesChanged) - if err := _Gateway.contract.UnpackLog(event, "TokenTransferFeesChanged", log); err != nil { +// Solidity: event OutboundMessageAccepted(uint64 nonce, uint256 reward, bytes payload) +func (_Gateway *GatewayFilterer) ParseOutboundMessageAccepted(log types.Log) (*GatewayOutboundMessageAccepted, error) { + event := new(GatewayOutboundMessageAccepted) + if err := _Gateway.contract.UnpackLog(event, "OutboundMessageAccepted", log); err != nil { return nil, err } event.Raw = log diff --git a/relayer/generate.go b/relayer/generate.go index 75303bdb83..2a9cef77a6 100644 --- a/relayer/generate.go +++ b/relayer/generate.go @@ -1,4 +1,4 @@ //go:generate bash -c "jq .abi ../contracts/out/BeefyClient.sol/BeefyClient.json | abigen --abi - --type BeefyClient --pkg contracts --out contracts/beefy_client.go" -//go:generate bash -c "jq .abi ../contracts/out/IGateway.sol/IGateway.json | abigen --abi - --type Gateway --pkg contracts --out contracts/gateway.go" +//go:generate bash -c "jq .abi ../contracts/out/IGateway.sol/IGatewayV2.json | abigen --abi - --type Gateway --pkg contracts --out contracts/gateway.go" package main diff --git a/relayer/relays/execution/main.go b/relayer/relays/execution/main.go index 099d263938..80b5bbd8b1 100644 --- a/relayer/relays/execution/main.go +++ b/relayer/relays/execution/main.go @@ -118,7 +118,7 @@ func (r *Relay) Start(ctx context.Context, eg *errgroup.Group) error { "channelId": r.config.Source.ChannelID, }).Info("Polling Nonces") - paraNonce, err := r.fetchLatestParachainNonce() + paraNonces, err := r.fetchUnprocessedParachainNonces() if err != nil { return err } @@ -130,32 +130,30 @@ func (r *Relay) Start(ctx context.Context, eg *errgroup.Group) error { log.WithFields(log.Fields{ "channelId": types.H256(r.config.Source.ChannelID).Hex(), - "paraNonce": paraNonce, + "paraNonces": paraNonces, "ethNonce": ethNonce, "instantVerification": r.config.InstantVerification, }).Info("Polled Nonces") - if paraNonce == ethNonce { - continue - } - blockNumber, err := ethconn.Client().BlockNumber(ctx) if err != nil { return fmt.Errorf("get last block number: %w", err) } - events, err := r.findEvents(ctx, blockNumber, paraNonce+1) - if err != nil { - return fmt.Errorf("find events: %w", err) - } + for _, paraNonce := range paraNonces { + events, err := r.findEvents(ctx, blockNumber, paraNonce+1) + if err != nil { + return fmt.Errorf("find events: %w", err) + } - for _, ev := range events { - err := r.waitAndSend(ctx, ev) - if errors.Is(err, header.ErrBeaconHeaderNotFinalized) { - log.WithField("nonce", ev.Nonce).Info("beacon header not finalized yet") - continue - } else if err != nil { - return fmt.Errorf("submit event: %w", err) + for _, ev := range events { + err := r.waitAndSend(ctx, ev) + if errors.Is(err, header.ErrBeaconHeaderNotFinalized) { + log.WithField("nonce", ev.Nonce).Info("beacon header not finalized yet") + continue + } else if err != nil { + return fmt.Errorf("submit event: %w", err) + } } } } @@ -197,38 +195,86 @@ func (r *Relay) writeToParachain(ctx context.Context, proof scale.ProofPayload, return nil } -func (r *Relay) fetchLatestParachainNonce() (uint64, error) { - paraID := r.config.Source.ChannelID - encodedParaID, err := types.EncodeToBytes(r.config.Source.ChannelID) +func (r *Relay) fetchUnprocessedParachainNonces() ([]uint64, error) { + unprocessedNonces := []uint64{} + startKey, err := types.CreateStorageKey(r.paraconn.Metadata(), "EthereumInboundQueue", "NonceBitmap", nil) + if err != nil { + return unprocessedNonces, fmt.Errorf("create storage key for EthereumInboundQueue.NonceBitmap: %w", err) + } + + blockHash, err := r.paraconn.API().RPC.Chain.GetBlockHashLatest() + if err != nil { + return unprocessedNonces, fmt.Errorf("fetch latest parachain block hash: %w", err) + } + + keys, err := r.paraconn.API().RPC.State.GetKeysPaged(startKey, 100, nil, blockHash) if err != nil { - return 0, err + return unprocessedNonces, fmt.Errorf("fetch storage EthereumInboundQueue.NonceBitmap keys: %w", err) } + for _, key := range keys { + var value types.U128 + ok, err := r.paraconn.API().RPC.State.GetStorageLatest(key, &value) + if err != nil { + return unprocessedNonces, fmt.Errorf("fetch latest parachain value: %w", err) + } + if !ok || value.Int.Cmp(big.NewInt(0)) == 0 { + continue // Skip empty buckets + } + + unprocessedNonces = extractUnprocessedNonces(value) + fmt.Printf("Unprocessed nonces for bucket %s: %v\n", key.Hex(), unprocessedNonces) + } + + return unprocessedNonces, nil +} - paraNonceKey, err := types.CreateStorageKey(r.paraconn.Metadata(), "EthereumInboundQueue", "Nonce", encodedParaID, nil) +func (r *Relay) isParachainNonceSet(index uint64) (bool, error) { + // Calculate the bucket and bit position + bucket := index / 128 + bitPosition := index % 128 + + encodedBucket, err := types.EncodeToBytes(types.NewU64(bucket)) + bucketKey, err := types.CreateStorageKey(r.paraconn.Metadata(), "EthereumInboundQueue", "NonceBitmap", encodedBucket) if err != nil { - return 0, fmt.Errorf("create storage key for EthereumInboundQueue.Nonce(%v): %w", - paraID, err) + return false, fmt.Errorf("create storage key for EthereumInboundQueue.NonceBitmap: %w", err) } - var paraNonce uint64 - ok, err := r.paraconn.API().RPC.State.GetStorageLatest(paraNonceKey, ¶Nonce) + + var bucketValue types.U128 + ok, err := r.paraconn.API().RPC.State.GetStorageLatest(bucketKey, &bucketValue) if err != nil { - return 0, fmt.Errorf("fetch storage EthereumInboundQueue.Nonce(%v): %w", - paraID, err) + return false, fmt.Errorf("fetch storage EthereumInboundQueue.NonceBitmap keys: %w", err) } if !ok { - paraNonce = 0 + return false, fmt.Errorf("bucket does not exist: %w", err) } - return paraNonce, nil + return checkBitState(bucketValue, bitPosition), nil +} + +func checkBitState(bucketValue types.U128, bitPosition uint64) bool { + mask := new(big.Int).Lsh(big.NewInt(1), uint(bitPosition)) // Create mask for the bit position + return new(big.Int).And(bucketValue.Int, mask).Cmp(big.NewInt(0)) != 0 +} + +func extractUnprocessedNonces(bitmap types.U128) []uint64 { + var unprocessed []uint64 + for i := 0; i < 128; i++ { + mask := new(big.Int).Lsh(big.NewInt(1), uint(i)) + bit := new(big.Int).And(bitmap.Int, mask) + if bit.Cmp(big.NewInt(0)) == 0 { + unprocessed = append(unprocessed, uint64(i)) + } + } + return unprocessed } func (r *Relay) fetchEthereumNonce(ctx context.Context) (uint64, error) { opts := bind.CallOpts{ Context: ctx, } - _, ethOutboundNonce, err := r.gatewayContract.ChannelNoncesOf(&opts, r.config.Source.ChannelID) + ethOutboundNonce, err := r.gatewayContract.OutboundNonce(&opts) if err != nil { - return 0, fmt.Errorf("fetch Gateway.ChannelNoncesOf(%v): %w", r.config.Source.ChannelID, err) + return 0, fmt.Errorf("fetch Gateway.OutboundNonce: %w", err) } return ethOutboundNonce, nil @@ -241,9 +287,6 @@ func (r *Relay) findEvents( latestFinalizedBlockNumber uint64, start uint64, ) ([]*contracts.GatewayOutboundMessageAccepted, error) { - - channelID := r.config.Source.ChannelID - var allEvents []*contracts.GatewayOutboundMessageAccepted blockNumber := latestFinalizedBlockNumber @@ -262,7 +305,7 @@ func (r *Relay) findEvents( Context: ctx, } - done, events, err := r.findEventsWithFilter(&opts, channelID, start) + done, events, err := r.findEventsWithFilter(&opts, start) if err != nil { return nil, fmt.Errorf("filter events: %w", err) } @@ -285,8 +328,8 @@ func (r *Relay) findEvents( return allEvents, nil } -func (r *Relay) findEventsWithFilter(opts *bind.FilterOpts, channelID [32]byte, start uint64) (bool, []*contracts.GatewayOutboundMessageAccepted, error) { - iter, err := r.gatewayContract.FilterOutboundMessageAccepted(opts, [][32]byte{channelID}, [][32]byte{}) +func (r *Relay) findEventsWithFilter(opts *bind.FilterOpts, start uint64) (bool, []*contracts.GatewayOutboundMessageAccepted, error) { + iter, err := r.gatewayContract.FilterOutboundMessageAccepted(opts) if err != nil { return false, nil, err } @@ -409,7 +452,6 @@ func (r *Relay) doSubmit(ctx context.Context, ev *contracts.GatewayOutboundMessa "blockNumber": ev.Raw.BlockNumber, "txHash": ev.Raw.TxHash.Hex(), "txIndex": ev.Raw.TxIndex, - "channelID": types.H256(ev.ChannelID).Hex(), }) nextBlockNumber := new(big.Int).SetUint64(ev.Raw.BlockNumber + 1) @@ -443,11 +485,8 @@ func (r *Relay) doSubmit(ctx context.Context, ev *contracts.GatewayOutboundMessa return fmt.Errorf("write to parachain: %w", err) } - paraNonce, err := r.fetchLatestParachainNonce() - if err != nil { - return fmt.Errorf("fetch latest parachain nonce: %w", err) - } - if paraNonce != ev.Nonce { + ok, err := r.isParachainNonceSet(ev.Nonce) + if !ok { return fmt.Errorf("inbound message fail to execute") } logger.Info("inbound message executed successfully") @@ -457,17 +496,21 @@ func (r *Relay) doSubmit(ctx context.Context, ev *contracts.GatewayOutboundMessa // isMessageProcessed checks if the provided event nonce has already been processed on-chain. func (r *Relay) isMessageProcessed(eventNonce uint64) (bool, error) { - paraNonce, err := r.fetchLatestParachainNonce() + paraNonces, err := r.fetchUnprocessedParachainNonces() if err != nil { return false, fmt.Errorf("fetch latest parachain nonce: %w", err) } // Check the nonce again in case another relayer processed the message while this relayer downloading beacon state - if eventNonce <= paraNonce { - log.WithField("nonce", paraNonce).Info("message picked up by another relayer, skipped") - return true, nil + + for _, paraNonce := range paraNonces { + if eventNonce == paraNonce { + log.WithField("nonce", paraNonce).Info("unprocessed message found") + return false, nil + } } - return false, nil + log.WithField("nonce", eventNonce).Info("processed message found") + return true, nil } // isInFinalizedBlock checks if the block containing the event is a finalized block. @@ -481,3 +524,7 @@ func (r *Relay) isInFinalizedBlock(ctx context.Context, event *contracts.Gateway return r.beaconHeader.CheckHeaderFinalized(*blockHeader.ParentBeaconRoot, r.config.InstantVerification) } + +func (r *Relay) UnprocessedNonces() { + +}